talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit a8e2db54e2828e3dc4e45f97af36bf0ef2bb902a
parent aadb7d5405e67c0823a624728652c01055c837f6
Author: Ricardo Mones <ricardo@mones.org>
Date:   Thu, 18 Jun 2015 02:13:28 +0200

Fix leak on failing realloc

Diffstat:
Msrc/plugins/pgpcore/sgpgme.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/plugins/pgpcore/sgpgme.c b/src/plugins/pgpcore/sgpgme.c @@ -979,11 +979,14 @@ void *sgpgme_data_release_and_get_mem(gpgme_data_t data, size_t *len) /* I know it's deprecated, but we don't compile with _LARGEFILE */ cm_gpgme_data_rewind(data); while ((r = gpgme_data_read(data, buf, BUFSIZ)) > 0) { - result = realloc(result, r + w); - if (result == NULL) { + void *rresult = realloc(result, r + w); + if (rresult == NULL) { g_warning("can't allocate memory\n"); + if (result != NULL) + free(result); return NULL; } + result = rresult; memcpy(result+w, buf, r); w += r; }