summaryrefslogtreecommitdiff
path: root/hiredis.c
diff options
context:
space:
mode:
Diffstat (limited to 'hiredis.c')
-rw-r--r--hiredis.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/hiredis.c b/hiredis.c
index 0b0db52..3aa3164 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -77,7 +77,7 @@ void freeReplyObject(void *reply) {
case REDIS_REPLY_INTEGER:
break; /* Nothing to free */
case REDIS_REPLY_ARRAY:
- if (r->elements > 0 && r->element != NULL) {
+ if (r->element != NULL) {
for (j = 0; j < r->elements; j++)
if (r->element[j] != NULL)
freeReplyObject(r->element[j]);
@@ -133,10 +133,12 @@ static void *createArrayObject(const redisReadTask *task, int elements) {
if (r == NULL)
return NULL;
- r->element = calloc(elements,sizeof(redisReply*));
- if (r->element == NULL) {
- freeReplyObject(r);
- return NULL;
+ if (elements > 0) {
+ r->element = calloc(elements,sizeof(redisReply*));
+ if (r->element == NULL) {
+ freeReplyObject(r);
+ return NULL;
+ }
}
r->elements = elements;