https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b92f1f4cdf3143eaad6d5…
commit b92f1f4cdf3143eaad6d5220c538c23658b759ec
Author: Serge Gautherie <reactos-git_serge_171003(a)gautherie.fr>
AuthorDate: Sun Aug 26 03:05:46 2018 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sat Dec 8 17:38:24 2018 +0100
[LOG2LINES] Free all memory on exit.
---
sdk/tools/log2lines/log2lines.c | 41 +++++++++++++++++++++++++++++++++++------
1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/sdk/tools/log2lines/log2lines.c b/sdk/tools/log2lines/log2lines.c
index 025ccaa49e..cbe9482f49 100644
--- a/sdk/tools/log2lines/log2lines.c
+++ b/sdk/tools/log2lines/log2lines.c
@@ -579,7 +579,8 @@ main(int argc, const char **argv)
if (optCount < 0 || optInit < 0)
{
- return optCount;
+ res = optCount;
+ goto cleanup;
}
argc -= optCount;
@@ -587,21 +588,30 @@ main(int argc, const char **argv)
if (opt_Revision && (strcmp(opt_Revision, "update") == 0))
{
res = updateSvnlog();
- return res;
+ goto cleanup;
}
if (check_directory(opt_force))
- return 3;
+ {
+ res = 3;
+ goto cleanup;
+ }
create_cache(opt_force, 0);
if (opt_exit)
- return 0;
+ {
+ res = 0;
+ goto cleanup;
+ }
read_cache();
l2l_dbg(4, "Cache read complete\n");
if (set_LogFile(&logFile))
- return 2;
+ {
+ res = 2;
+ goto cleanup;
+ }
l2l_dbg(4, "opt_logFile processed\n");
if (opt_Pipe)
@@ -612,7 +622,8 @@ main(int argc, const char **argv)
{
dbgIn = stdin; //restore
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");
@@ -662,6 +673,24 @@ main(int argc, const char **argv)
if (opt_Pipe)
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;
}