Add empty pointer check in error cleanup

If realloc fails, the curargv will be NULL.

Closes #253
This commit is contained in:
NanXiao 2014-07-14 16:34:49 +08:00 committed by Matt Stancliff
parent d1e820d8ee
commit e30c96ebde

View File

@ -895,12 +895,13 @@ int redisvFormatCommand(char **target, const char *format, va_list ap) {
return totlen; return totlen;
err: err:
while(argc--) if (curargv) {
sdsfree(curargv[argc]); while(argc--)
free(curargv); sdsfree(curargv[argc]);
free(curargv);
}
if (curarg != NULL) sdsfree(curarg);
sdsfree(curarg);
/* No need to check cmd since it is the last statement that can fail, /* No need to check cmd since it is the last statement that can fail,
* but do it anyway to be as defensive as possible. */ * but do it anyway to be as defensive as possible. */