Skip to content

Commit 7f42d62

Browse files
committed
Set error message and fix memory leak.
1 parent c0db75b commit 7f42d62

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

library.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,16 +2112,19 @@ PHP_REDIS_API int redis_mbulk_reply_assoc(INTERNAL_FUNCTION_PARAMETERS, RedisSoc
21122112
zval *z_keys = ctx;
21132113

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

2118-
if(inbuf[0] != '*') {
2118+
if (*inbuf != TYPE_MULTIBULK) {
21192119
if (IS_ATOMIC(redis_sock)) {
21202120
RETVAL_FALSE;
21212121
} else {
21222122
add_next_index_bool(z_tab, 0);
21232123
}
2124-
return -1;
2124+
if (*inbuf == TYPE_ERR) {
2125+
redis_sock_set_err(redis_sock, inbuf + 1, len);
2126+
}
2127+
goto failure;
21252128
}
21262129
numElems = atoi(inbuf+1);
21272130
zval z_multi_result;
@@ -2151,7 +2154,15 @@ PHP_REDIS_API int redis_mbulk_reply_assoc(INTERNAL_FUNCTION_PARAMETERS, RedisSoc
21512154
} else {
21522155
add_next_index_zval(z_tab, &z_multi_result);
21532156
}
2154-
return 0;
2157+
return SUCCESS;
2158+
failure:
2159+
if (z_keys != NULL) {
2160+
for (i = 0; Z_TYPE(z_keys[i]) != IS_NULL; ++i) {
2161+
zval_dtor(&z_keys[i]);
2162+
}
2163+
efree(z_keys);
2164+
}
2165+
return FAILURE;
21552166
}
21562167

21572168
/**

0 commit comments

Comments
 (0)