agent: Fix memory leaks in multiple codes
Joshua Rogers
git at internot.info
Tue Dec 23 21:52:15 CET 2014
* agent/command.c free 'cache_nonce' before return
* agent/protect.c free 'newlist' before return
--
Signed-off-by: Joshua Rogers <git at internot.info>
---
agent/command.c | 3 +++
agent/protect.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/agent/command.c b/agent/command.c
index da7e508..16f2218 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -962,7 +962,10 @@ cmd_genkey (assuan_context_t ctx, char *line)
if (!rc)
rc = assuan_inquire (ctx, "KEYPARAM", &value, &valuelen, MAXLEN_KEYPARAM);
if (rc)
+ {
+ xfree (cache_nonce);
return rc;
+ }
init_membuf (&outbuf, 512);
diff --git a/agent/protect.c b/agent/protect.c
index 01e72c2..2874365 100644
--- a/agent/protect.c
+++ b/agent/protect.c
@@ -750,7 +750,10 @@ merge_lists (const unsigned char *protectedkey,
/* copy the cleartext */
s = cleartext;
if (*s != '(' && s[1] != '(')
+ {
+ xfree (newlist);
return gpg_error (GPG_ERR_BUG); /*we already checked this */
+ }
s += 2;
startpos = s;
while ( *s == '(' )
--
1.9.1
More information about the Gnupg-devel
mailing list