redis-check-dump: Prevent segfault if can't malloc

Found by The Mayhem Team (Alexandre Rebert, Thanassis Avgerinos,
Sang Kil Cha, David Brumley, Manuel Egele) Cylab, Carnegie Mellon
University. See http://bugs.debian.org/716259 for more.

Signed-off-by: Chris Lamb <lamby@debian.org>

Fixes #1191
This commit is contained in:
Chris Lamb 2013-07-11 12:45:15 +01:00 committed by antirez
parent 354119e4c5
commit af62d9a687

View File

@ -337,6 +337,7 @@ char* loadStringObject() {
if (len == REDIS_RDB_LENERR) return NULL; if (len == REDIS_RDB_LENERR) return NULL;
char *buf = malloc(sizeof(char) * (len+1)); char *buf = malloc(sizeof(char) * (len+1));
if (buf == NULL) return NULL;
buf[len] = '\0'; buf[len] = '\0';
if (!readBytes(buf, len)) { if (!readBytes(buf, len)) {
free(buf); free(buf);