@@ -131,10 +131,14 @@ static struct row *row_init(const int trace, const size_t first_delim, char *lin
131131 return row ;
132132}
133133
134- static void row_destroy (struct row * row ) {
134+ static void row_destroy (struct row * * ref ) {
135135 /* Not checking arguments */
136+
137+ struct row * row = * ref ;
136138 free (row -> line );
137139 free (row );
140+
141+ * ref = NULL ;
138142}
139143
140144#ifdef DEBUG
@@ -233,7 +237,7 @@ static int processdir(QPTPool_t *ctx, const size_t id, void *data, void *args) {
233237 const int err = errno ;
234238 fprintf (stderr , "Dupdir failure: \"%s\": %s (%d)\n" ,
235239 topath , strerror (err ), err );
236- row_destroy (w );
240+ row_destroy (& w );
237241 return 1 ;
238242 }
239243 timestamp_set_end (dupdir );
@@ -442,7 +446,7 @@ static int processdir(QPTPool_t *ctx, const size_t id, void *data, void *args) {
442446 }
443447
444448 timestamp_create_start (row_destroy );
445- row_destroy (w );
449+ row_destroy (& w );
446450 timestamp_set_end (row_destroy );
447451
448452 #ifdef DEBUG
@@ -558,13 +562,10 @@ static int scout_function(QPTPool_t *ctx, const size_t id, void *data, void *arg
558562 * bad line
559563 */
560564 if (!first_delim ) {
561- free (line );
562- line = NULL ;
563- size = 0 ;
564- len = 0 ;
565+ row_destroy (& work );
565566 fprintf (stderr , "Scout encountered bad line ending at %s offset %jd\n" ,
566567 sa -> tracename , (intmax_t ) offset );
567- return 1 ;
568+ break ;
568569 }
569570
570571 /* push directories onto queues */
@@ -596,10 +597,12 @@ static int scout_function(QPTPool_t *ctx, const size_t id, void *data, void *arg
596597
597598 free (line );
598599
599- /* handle the last work item */
600- dir_count ++ ;
601- empty += !work -> entries ;
602- QPTPool_enqueue (ctx , id , processdir , work );
600+ if (work ) {
601+ /* handle the last work item */
602+ dir_count ++ ;
603+ empty += !work -> entries ;
604+ QPTPool_enqueue (ctx , id , processdir , work );
605+ }
603606
604607 clock_gettime (CLOCK_MONOTONIC , & scouting .end );
605608
0 commit comments