From 6f16e0d3dafb6e54ea6f98a304d5bf90ab8dbd0f Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 30 Apr 2014 15:53:26 -0400 Subject: [PATCH] don't leak if first realloc fails but second one succeeds --- src/mod/applications/mod_redis/credis.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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;