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>
This commit is contained in:
Jakub Jelen 2021-04-07 17:58:10 +02:00 committed by NIIBE Yutaka
parent c0b1bcc5c6
commit 50f32eb066
1 changed files with 4 additions and 1 deletions

View File

@ -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 == '(' )