aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2014-05-23 13:24:37 +0200
committerMichael Tokarev <mjt@tls.msk.ru>2014-05-24 00:46:20 +0400
commit26b78f4d3c3f45f84067440e56c3ebf2d25a9574 (patch)
tree18b701bec9b4e8849079f9dac7dc9881e935d098
parentf33a984d512dbcb6762b002a65de4ea748e31d4a (diff)
downloadqemu-26b78f4d3c3f45f84067440e56c3ebf2d25a9574.zip
qemu-26b78f4d3c3f45f84067440e56c3ebf2d25a9574.tar.gz
qemu-26b78f4d3c3f45f84067440e56c3ebf2d25a9574.tar.bz2
libcacard: Convert two leftover realloc() to GLib
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Alon Levy <alevy@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
-rw-r--r--libcacard/cac.c13
-rw-r--r--libcacard/vcard_emul_nss.c7
2 files changed, 4 insertions, 16 deletions
diff --git a/libcacard/cac.c b/libcacard/cac.c
index 122129e..3887896 100644
--- a/libcacard/cac.c
+++ b/libcacard/cac.c
@@ -169,17 +169,8 @@ cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
}
size = apdu->a_Lc;
- sign_buffer = realloc(pki_applet->sign_buffer,
- pki_applet->sign_buffer_len+size);
- if (sign_buffer == NULL) {
- g_free(pki_applet->sign_buffer);
- pki_applet->sign_buffer = NULL;
- pki_applet->sign_buffer_len = 0;
- *response = vcard_make_response(
- VCARD7816_STATUS_EXC_ERROR_MEMORY_FAILURE);
- ret = VCARD_DONE;
- break;
- }
+ sign_buffer = g_realloc(pki_applet->sign_buffer,
+ pki_applet->sign_buffer_len + size);
memcpy(sign_buffer+pki_applet->sign_buffer_len, apdu->a_body, size);
size += pki_applet->sign_buffer_len;
switch (apdu->a_p1) {
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index 7826593..8e05551 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -1178,11 +1178,8 @@ vcard_emul_options(const char *args)
if (opts->vreader_count >= reader_count) {
reader_count += READER_STEP;
- vreaderOpt = realloc(opts->vreader,
- reader_count * sizeof(*vreaderOpt));
- if (vreaderOpt == NULL) {
- return opts; /* we're done */
- }
+ vreaderOpt = g_renew(VirtualReaderOptions, opts->vreader,
+ reader_count);
}
opts->vreader = vreaderOpt;
vreaderOpt = &vreaderOpt[opts->vreader_count];