summaryrefslogtreecommitdiff
path: root/libcacard
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2011-07-04 18:10:43 +0200
committerAlon Levy <alevy@redhat.com>2011-07-22 18:05:36 +0300
commit163c1c7246b8ce115d9110e3a9f062cd1167de1c (patch)
treecac8e4e6e900036f9d9d40e070d59cd5844b14b2 /libcacard
parentda1811488dd3845d4d46f92d4c36d69adb6d6750 (diff)
downloadqemu-163c1c7246b8ce115d9110e3a9f062cd1167de1c.tar.gz
qemu-163c1c7246b8ce115d9110e3a9f062cd1167de1c.tar.bz2
qemu-163c1c7246b8ce115d9110e3a9f062cd1167de1c.zip
libcacard: don't leak vcard_emul_alloc_arrays mem
vcard_emul_mirror_card and vcard_emul_init use vcard_emul_alloc_arrays to allocate memory for temporary arrays which will contain elements that in the end will be used one by one in cac_card_init. The arrays themselves are never stored anywhere, they are only used as temporary containers. Hence the memory that was allocated for these arrays should be freed after use or they will be leaked.
Diffstat (limited to 'libcacard')
-rw-r--r--libcacard/vcard_emul_nss.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index 0f5095405f..f1763f55f7 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -597,6 +597,7 @@ vcard_emul_mirror_card(VReader *vreader)
VCardKey **keys;
PK11SlotInfo *slot;
PRBool ret;
+ VCard *card;
slot = vcard_emul_reader_get_slot(vreader);
if (slot == NULL) {
@@ -656,7 +657,12 @@ vcard_emul_mirror_card(VReader *vreader)
}
/* now create the card */
- return vcard_emul_make_card(vreader, certs, cert_len, keys, cert_count);
+ card = vcard_emul_make_card(vreader, certs, cert_len, keys, cert_count);
+ qemu_free(certs);
+ qemu_free(cert_len);
+ qemu_free(keys);
+
+ return card;
}
static VCardEmulType default_card_type = VCARD_EMUL_NONE;
@@ -941,6 +947,9 @@ vcard_emul_init(const VCardEmulOptions *options)
vreader_free(vreader);
has_readers = PR_TRUE;
}
+ qemu_free(certs);
+ qemu_free(cert_len);
+ qemu_free(keys);
}
/* if we aren't suppose to use hw, skip looking up hardware tokens */