Re: [PATCH 16 of 16] free intermediates in error path
> Hi,
>
> * Erik Hovland wrote:
>
>> Static analyzers do shine. But only when humans use them right. Here
>> is the corrected patch for the same thing after fixing my usage of the
>> tool.
>
> Sorry for being so tenacious on this issue.
Don't be sorry, it is appreciated.
> I'm still not convinced this is right. The first free is okay. But in
> case of no error and intermediates == NULL, it's set to SmimeDefaultKey
> which is a config value. If you later free that, you free the config
> value.
>
> So I think that all subsequent FREE calls should actually be made only
> if intermediates != SmimeDefaultKey perhaps with a label and goto.
Patch that does this attached.
E
--
Erik Hovland
erik@xxxxxxxxxxx
http://hovland.org/
diff -r 856f28ea3b64 smime.c
--- a/smime.c Tue Mar 17 12:06:21 2009 -0700
+++ b/smime.c Tue Mar 17 13:33:48 2009 -0700
@@ -1387,6 +1387,7 @@
if (!SmimeDefaultKey)
{
mutt_error _("Can't sign: No key specified. Use Sign As.");
+ FREE (&intermediates);
return NULL;
}
@@ -1402,6 +1403,7 @@
if ((sfp = safe_fopen (filetosign, "w+")) == NULL)
{
mutt_perror (filetosign);
+ if (intermediates != SmimeDefaultKey) FREE (&intermediates);
return NULL;
}
@@ -1411,6 +1413,7 @@
mutt_perror (signedfile);
safe_fclose (&sfp);
mutt_unlink (filetosign);
+ if (intermediates != SmimeDefaultKey) FREE (&intermediates);
return NULL;
}
@@ -1439,6 +1442,7 @@
safe_fclose (&smimeout);
mutt_unlink (signedfile);
mutt_unlink (filetosign);
+ if (intermediates != SmimeDefaultKey) FREE (&intermediates);
return NULL;
}
fputs (SmimePass, smimein);