don't leak if first realloc fails but second one succeeds
This commit is contained in:
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)",
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue