From 8a7b30d3f01f1b2f0140a9a319850b87d4b20a65 Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Mon, 17 Oct 2016 14:37:20 -0700 Subject: [PATCH] Fix null pointer deref in job_reap() Coverity believes in this one in job_reap(). Proactively apply same check to format_job_info(). --- src/proc.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/proc.cpp b/src/proc.cpp index 1cdaece4f..a5199c71b 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -503,7 +503,10 @@ static void format_job_info(const job_t *j, const wchar_t *status, size_t job_co truncate_command(j->command()).c_str(), status); } fflush(stdout); - tputs(clr_eol, 1, &writeb); + if (cur_term != NULL) + tputs(clr_eol, 1, &writeb); + else + fwprintf(stdout, L"\x1b[K"); fwprintf(stdout, L"\n"); } @@ -605,7 +608,13 @@ int job_reap(bool allow_interactive) { sig2wcs(WTERMSIG(p->status)), signal_get_desc(WTERMSIG(p->status))); } - tputs(clr_eol, 1, &writeb); + + if (cur_term != NULL) + tputs(clr_eol, 1, &writeb); + else + fwprintf(stdout, + L"\x1b[K"); // no term set up - do clr_eol manually + fwprintf(stdout, L"\n"); } found = 1;