[LOG2LINES] Free all memory on exit.

This commit is contained in:
Serge Gautherie 2018-08-26 03:05:46 +02:00 committed by Hermès Bélusca-Maïto
parent ca2bb9ee28
commit b92f1f4cdf
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -579,7 +579,8 @@ main(int argc, const char **argv)
if (optCount < 0 || optInit < 0) if (optCount < 0 || optInit < 0)
{ {
return optCount; res = optCount;
goto cleanup;
} }
argc -= optCount; argc -= optCount;
@ -587,21 +588,30 @@ main(int argc, const char **argv)
if (opt_Revision && (strcmp(opt_Revision, "update") == 0)) if (opt_Revision && (strcmp(opt_Revision, "update") == 0))
{ {
res = updateSvnlog(); res = updateSvnlog();
return res; goto cleanup;
} }
if (check_directory(opt_force)) if (check_directory(opt_force))
return 3; {
res = 3;
goto cleanup;
}
create_cache(opt_force, 0); create_cache(opt_force, 0);
if (opt_exit) if (opt_exit)
return 0; {
res = 0;
goto cleanup;
}
read_cache(); read_cache();
l2l_dbg(4, "Cache read complete\n"); l2l_dbg(4, "Cache read complete\n");
if (set_LogFile(&logFile)) if (set_LogFile(&logFile))
return 2; {
res = 2;
goto cleanup;
}
l2l_dbg(4, "opt_logFile processed\n"); l2l_dbg(4, "opt_logFile processed\n");
if (opt_Pipe) if (opt_Pipe)
@ -612,7 +622,8 @@ main(int argc, const char **argv)
{ {
dbgIn = stdin; //restore dbgIn = stdin; //restore
l2l_dbg(0, "Could not popen '%s' (%s)\n", opt_Pipe, strerror(errno)); l2l_dbg(0, "Could not popen '%s' (%s)\n", opt_Pipe, strerror(errno));
free(opt_Pipe); opt_Pipe = NULL; free(opt_Pipe);
opt_Pipe = NULL;
} }
} }
l2l_dbg(4, "opt_Pipe processed\n"); l2l_dbg(4, "opt_Pipe processed\n");
@ -662,6 +673,24 @@ main(int argc, const char **argv)
if (opt_Pipe) if (opt_Pipe)
PCLOSE(dbgIn); PCLOSE(dbgIn);
cleanup:
// See optionParse().
if (opt_Revision)
{
free(opt_Revision);
opt_Revision = NULL;
}
// See optionInit().
if (opt_Pipe)
{
free(opt_Pipe);
opt_Pipe = NULL;
}
list_clear(&sources);
list_clear(&cache);
return res; return res;
} }