diff options
author | NanXiao <xn212516@163.com> | 2014-07-14 16:34:49 +0800 |
---|---|---|
committer | Matt Stancliff <matt@genges.com> | 2015-01-05 16:39:30 -0500 |
commit | e30c96ebdec4e8612f4102f9cd99d36488c66e5c (patch) | |
tree | 952947f6017c556e4279d1dddac39d07ac2215ef | |
parent | d1e820d8ee01583e1db13ff27ec32dc94e18641d (diff) |
Add empty pointer check in error cleanup
If realloc fails, the curargv will be NULL.
Closes #253
-rw-r--r-- | hiredis.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -895,12 +895,13 @@ int redisvFormatCommand(char **target, const char *format, va_list ap) { return totlen; err: - while(argc--) - sdsfree(curargv[argc]); - free(curargv); + if (curargv) { + while(argc--) + 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, * but do it anyway to be as defensive as possible. */ |