summaryrefslogtreecommitdiffstats
path: root/agent/protect.c
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2021-04-07 17:58:10 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2021-11-12 07:35:56 +0100
commit50f32eb0664d921242563f6602ce5a8f46557085 (patch)
treea9bd72e4835cefcde5bcd60e2225e20929706dc3 /agent/protect.c
parentscd: Avoid memory leak. (diff)
downloadgnupg2-50f32eb0664d921242563f6602ce5a8f46557085.tar.xz
gnupg2-50f32eb0664d921242563f6602ce5a8f46557085.zip
agent: Correctly free memory on error path.
* agent/protect.c (merge_lists): Free memory on error. -- GnuPG-bug-id: 5393 Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'agent/protect.c')
-rw-r--r--agent/protect.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/agent/protect.c b/agent/protect.c
index 4ceb3006e..30ee1345d 100644
--- a/agent/protect.c
+++ b/agent/protect.c
@@ -970,7 +970,10 @@ merge_lists (const unsigned char *protectedkey,
/* Copy the cleartext. */
s = cleartext;
if (*s != '(' && s[1] != '(')
- return gpg_error (GPG_ERR_BUG); /*we already checked this */
+ {
+ xfree (newlist);
+ return gpg_error (GPG_ERR_BUG); /*we already checked this */
+ }
s += 2;
startpos = s;
while ( *s == '(' )