From a215aa14fac8a8b08fc4a209ddb8f53bd8265a3e Mon Sep 17 00:00:00 2001 From: PartialVolume Date: Tue, 10 Dec 2019 23:29:42 +0000 Subject: [PATCH] Fix segfault & missing log lines This patch fixes a segfault that occurs when a logfile is specified. The segfault occurred on exit of nwipe. It did not affect the wipe process. This patch also fixes a related issue, at the end of a wipe some of the log lines were missing on stdout, this occurred when a log file was not specified as an option. --- src/logging.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/logging.c b/src/logging.c index d845c83..33be313 100644 --- a/src/logging.c +++ b/src/logging.c @@ -280,10 +280,6 @@ void nwipe_log( nwipe_log_t level, const char* format, ... ) { printf( "%s\n", log_lines[log_current_element] ); } - else - { - log_current_element++; - } } else { /* Open the log file for appending. */ @@ -343,6 +339,8 @@ void nwipe_log( nwipe_log_t level, const char* format, ... ) } } + log_current_element++; + r = pthread_mutex_unlock( &mutex1 ); if ( r !=0 ) {