Skip to content

Commit 8d3839b

Browse files
Replace stack allocated zvals with stack or heap allocated zvals depending
on version of php.
1 parent c14d5bc commit 8d3839b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cluster_library.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2018,7 +2018,7 @@ PHP_REDIS_API int cluster_scan_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *
20182018
PHP_REDIS_API void cluster_info_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c,
20192019
void *ctx)
20202020
{
2021-
zval zv, *z_result = &zv;
2021+
zval *z_result;
20222022
char *info;
20232023

20242024
// Read our bulk response
@@ -2028,6 +2028,7 @@ PHP_REDIS_API void cluster_info_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster
20282028
}
20292029

20302030
/* Parse response, free memory */
2031+
PHPREDIS_STD_ZVAL(z_result);
20312032
redis_parse_info_response(info, z_result);
20322033
efree(info);
20332034

redis_cluster.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ PHP_METHOD(RedisCluster, keys) {
10431043
strlen_t pat_len;
10441044
char *pat, *cmd;
10451045
clusterReply *resp;
1046-
zval zv, *z_ret = &zv;
1046+
zval *z_ret;
10471047
int i, pat_free, cmd_len;
10481048

10491049
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pat, &pat_len)
@@ -1057,6 +1057,7 @@ PHP_METHOD(RedisCluster, keys) {
10571057
cmd_len = redis_cmd_format_static(&cmd, "KEYS", "s", pat, pat_len);
10581058
if(pat_free) efree(pat);
10591059

1060+
PHPREDIS_STD_ZVAL(z_ret);
10601061
array_init(z_ret);
10611062

10621063
/* Treat as readonly */
@@ -2078,10 +2079,11 @@ PHP_METHOD(RedisCluster, _unserialize) {
20782079
PHP_METHOD(RedisCluster, _masters) {
20792080
redisCluster *c = GET_CONTEXT();
20802081
redisClusterNode *node;
2081-
zval zv, *z_ret = &zv;
2082+
zval *z_ret;
20822083
char *host;
20832084
short port;
20842085

2086+
PHPREDIS_STD_ZVAL(z_ret);
20852087
array_init(z_ret);
20862088

20872089
for(zend_hash_internal_pointer_reset(c->nodes);

0 commit comments

Comments
 (0)