main: also free memory on errors

* src/derives.c (derives_free): Beware of NULL.
* src/main.c (main): Let the 'finish' label include memory release.
This commit is contained in:
Akim Demaille
2019-10-21 17:03:44 +02:00
parent d6fe39cd18
commit ec64a0bc7e
2 changed files with 7 additions and 4 deletions

View File

@@ -108,7 +108,10 @@ derives_compute (void)
void void
derives_free (void) derives_free (void)
{
if (derives)
{ {
free (derives[0]); free (derives[0]);
free (derives); free (derives);
} }
}

View File

@@ -207,6 +207,8 @@ main (int argc, char *argv[])
timevar_pop (tv_parser); timevar_pop (tv_parser);
} }
finish:
timevar_push (tv_free); timevar_push (tv_free);
nullable_free (); nullable_free ();
derives_free (); derives_free ();
@@ -228,8 +230,6 @@ main (int argc, char *argv[])
if (trace_flag & trace_bitsets) if (trace_flag & trace_bitsets)
bitset_stats_dump (stderr); bitset_stats_dump (stderr);
finish:
/* Stop timing and print the times. */ /* Stop timing and print the times. */
timevar_stop (tv_total); timevar_stop (tv_total);
timevar_print (stderr); timevar_print (stderr);