Skip to content

Commit

Permalink
Issue #1643
Browse files Browse the repository at this point in the history
Set error message and fix memory leak.
  • Loading branch information
yatsukhnenko committed Oct 5, 2019
1 parent c0db75b commit 7f42d62
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions library.c
Original file line number Diff line number Diff line change
Expand Up @@ -2112,16 +2112,19 @@ PHP_REDIS_API int redis_mbulk_reply_assoc(INTERNAL_FUNCTION_PARAMETERS, RedisSoc
zval *z_keys = ctx;

if (redis_sock_gets(redis_sock, inbuf, sizeof(inbuf) - 1, &len) < 0) {
return -1;
goto failure;
}

if(inbuf[0] != '*') {
if (*inbuf != TYPE_MULTIBULK) {
if (IS_ATOMIC(redis_sock)) {
RETVAL_FALSE;
} else {
add_next_index_bool(z_tab, 0);
}
return -1;
if (*inbuf == TYPE_ERR) {
redis_sock_set_err(redis_sock, inbuf + 1, len);
}
goto failure;
}
numElems = atoi(inbuf+1);
zval z_multi_result;
Expand Down Expand Up @@ -2151,7 +2154,15 @@ PHP_REDIS_API int redis_mbulk_reply_assoc(INTERNAL_FUNCTION_PARAMETERS, RedisSoc
} else {
add_next_index_zval(z_tab, &z_multi_result);
}
return 0;
return SUCCESS;
failure:
if (z_keys != NULL) {
for (i = 0; Z_TYPE(z_keys[i]) != IS_NULL; ++i) {
zval_dtor(&z_keys[i]);
}
efree(z_keys);
}
return FAILURE;
}

/**
Expand Down

0 comments on commit 7f42d62

Please sign in to comment.