]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
don't leak if first realloc fails but second one succeeds
authorMichael Jerris <mike@jerris.com>
Wed, 30 Apr 2014 19:53:26 +0000 (15:53 -0400)
committerMichael Jerris <mike@jerris.com>
Wed, 30 Apr 2014 19:53:26 +0000 (15:53 -0400)
src/mod/applications/mod_redis/credis.c

index a76cbedf49c510707968099db9ddca5de5a78579..8f1b749e670b11d8fd26872b90c379aa445b1ed4 100644 (file)
@@ -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;