1
0
mirror of https://github.com/signalwire/freeswitch.git synced 2025-03-06 02:22:56 +00:00

don't leak if first realloc fails but second one succeeds

This commit is contained in:
Michael Jerris 2014-04-30 15:53:26 -04:00
parent 068ad205b7
commit 6f16e0d3da

@ -162,9 +162,13 @@ static int cr_morebulk(cr_multibulk *mb, int size)
DEBUG("allocate %d x CR_MULTIBULK_SIZE, total %d (%lu bytes)", DEBUG("allocate %d x CR_MULTIBULK_SIZE, total %d (%lu bytes)",
n, total, total * ((sizeof(char *)+sizeof(int)))); n, total, total * ((sizeof(char *)+sizeof(int))));
cptr = realloc(mb->bulks, total * sizeof(char *)); cptr = realloc(mb->bulks, total * sizeof(char *));
if (cptr == NULL)
return CREDIS_ERR_NOMEM;
iptr = realloc(mb->idxs, total * sizeof(int)); iptr = realloc(mb->idxs, total * sizeof(int));
if (cptr == NULL || iptr == NULL) if (iptr == NULL)
return CREDIS_ERR_NOMEM; return CREDIS_ERR_NOMEM;
mb->bulks = cptr; mb->bulks = cptr;