1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-05 23:07:49 +02:00

g10: Fix memory leaks.

* g10/keydb.c (keydb_get_keyblock): Free 'sigstatus' and 'iobuf'.
* g10/t-keydb-get-keyblock.c: Fix trivial memory leaks.
* g10/t-keydb.c: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-06-28 18:02:10 +02:00
parent c14ef10fc3
commit c57501cc5f
3 changed files with 20 additions and 14 deletions

View File

@ -1387,11 +1387,8 @@ keydb_get_keyblock (KEYDB_HANDLE hd, KBNODE *ret_kb)
hd->keyblock_cache.pk_no = pk_no; hd->keyblock_cache.pk_no = pk_no;
hd->keyblock_cache.uid_no = uid_no; hd->keyblock_cache.uid_no = uid_no;
} }
else xfree (sigstatus);
{ iobuf_close (iobuf);
xfree (sigstatus);
iobuf_close (iobuf);
}
} }
} }
break; break;

View File

@ -59,4 +59,6 @@ do_test (int argc, char *argv[])
rc = keydb_get_keyblock (hd1, &kb1); rc = keydb_get_keyblock (hd1, &kb1);
TEST_P ("", ! rc); TEST_P ("", ! rc);
keydb_release (hd1);
} }

View File

@ -27,7 +27,7 @@ do_test (int argc, char *argv[])
int rc; int rc;
KEYDB_HANDLE hd1, hd2; KEYDB_HANDLE hd1, hd2;
KEYDB_SEARCH_DESC desc1, desc2; KEYDB_SEARCH_DESC desc1, desc2;
KBNODE kb1, kb2; KBNODE kb1, kb2, p;
char *uid1; char *uid1;
char *uid2; char *uid2;
char *fname; char *fname;
@ -75,17 +75,19 @@ do_test (int argc, char *argv[])
if (rc) if (rc)
ABORT ("Failed to get keyblock for DBFC6AD9"); ABORT ("Failed to get keyblock for DBFC6AD9");
while (kb1 && kb1->pkt->pkttype != PKT_USER_ID) p = kb1;
kb1 = kb1->next; while (p && p->pkt->pkttype != PKT_USER_ID)
if (! kb1) p = p->next;
if (! p)
ABORT ("DBFC6AD9 has no user id packet"); ABORT ("DBFC6AD9 has no user id packet");
uid1 = kb1->pkt->pkt.user_id->name; uid1 = p->pkt->pkt.user_id->name;
while (kb2 && kb2->pkt->pkttype != PKT_USER_ID) p = kb2;
kb2 = kb2->next; while (p && p->pkt->pkttype != PKT_USER_ID)
if (! kb2) p = p->next;
if (! p)
ABORT ("1E42B367 has no user id packet"); ABORT ("1E42B367 has no user id packet");
uid2 = kb2->pkt->pkt.user_id->name; uid2 = p->pkt->pkt.user_id->name;
if (verbose) if (verbose)
{ {
@ -94,4 +96,9 @@ do_test (int argc, char *argv[])
} }
TEST_P ("cache consistency", strcmp (uid1, uid2) != 0); TEST_P ("cache consistency", strcmp (uid1, uid2) != 0);
release_kbnode (kb1);
release_kbnode (kb2);
keydb_release (hd1);
keydb_release (hd2);
} }