From: Michael Jerris Date: Wed, 30 Apr 2014 19:53:26 +0000 (-0400) Subject: don't leak if first realloc fails but second one succeeds X-Git-Tag: v1.5.12~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f16e0d3dafb6e54ea6f98a304d5bf90ab8dbd0f;p=thirdparty%2Ffreeswitch.git don't leak if first realloc fails but second one succeeds --- diff --git a/src/mod/applications/mod_redis/credis.c b/src/mod/applications/mod_redis/credis.c index a76cbedf49..8f1b749e67 100644 --- a/src/mod/applications/mod_redis/credis.c +++ b/src/mod/applications/mod_redis/credis.c @@ -162,9 +162,13 @@ static int cr_morebulk(cr_multibulk *mb, int size) DEBUG("allocate %d x CR_MULTIBULK_SIZE, total %d (%lu bytes)", n, total, total * ((sizeof(char *)+sizeof(int)))); cptr = realloc(mb->bulks, total * sizeof(char *)); + + if (cptr == NULL) + return CREDIS_ERR_NOMEM; + iptr = realloc(mb->idxs, total * sizeof(int)); - if (cptr == NULL || iptr == NULL) + if (iptr == NULL) return CREDIS_ERR_NOMEM; mb->bulks = cptr;