提交 6f16e0d3 authored 作者: Michael Jerris's avatar Michael Jerris

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

上级 068ad205
......@@ -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;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论