Skip to content

Commit 0c351f5

Browse files
authored
Merge pull request phpredis#1028 from yatsukhnenko/develop
fix crash on FreeBSD and CentOS
2 parents f04811e + ad9f4ea commit 0c351f5

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

redis_array_impl.c

+7-10
Original file line numberDiff line numberDiff line change
@@ -1147,23 +1147,21 @@ ra_move_key(const char *key, int key_len, zval *z_from, zval *z_to TSRMLS_DC) {
11471147

11481148
/* callback with the current progress, with hostname and count */
11491149
static void zval_rehash_callback(zend_fcall_info *z_cb, zend_fcall_info_cache *z_cb_cache,
1150-
const char *hostname, long count TSRMLS_DC) {
1150+
const char *hostname, long count, zval *z_ret TSRMLS_DC) {
11511151

11521152
zval z_args[2];
11531153

11541154
ZVAL_STRING(&z_args[0], hostname);
11551155
ZVAL_LONG(&z_args[1], count);
11561156

11571157
#if (PHP_MAJOR_VERSION < 7)
1158-
zval *z_ret = NULL,
1159-
*z_host = &z_args[0], *z_count = &z_args[1],
1158+
zval *z_host = &z_args[0], *z_count = &z_args[1],
11601159
**z_args_pp[2] = { &z_host, &z_count };
11611160
z_cb->params = z_args_pp;
11621161
z_cb->retval_ptr_ptr = &z_ret;
11631162
#else
1164-
zval z_ret;
11651163
z_cb->params = z_args;
1166-
z_cb->retval = &z_ret;
1164+
z_cb->retval = z_ret;
11671165
#endif
11681166
z_cb->param_count = 2;
11691167
z_cb->no_separation = 0;
@@ -1173,18 +1171,16 @@ static void zval_rehash_callback(zend_fcall_info *z_cb, zend_fcall_info_cache *z
11731171

11741172
/* cleanup */
11751173
zval_dtor(&z_args[0]);
1176-
zval_ptr_dtor(&z_ret);
11771174
}
11781175

11791176
static void
11801177
ra_rehash_server(RedisArray *ra, zval *z_redis, const char *hostname, zend_bool b_index,
11811178
zend_fcall_info *z_cb, zend_fcall_info_cache *z_cb_cache TSRMLS_DC) {
11821179

11831180
char **keys;
1184-
int *key_lens;
11851181
long count, i;
1186-
int target_pos;
1187-
zval *z_target;
1182+
int *key_lens, target_pos;
1183+
zval *z_target, z_ret;
11881184

11891185
/* list all keys */
11901186
if(b_index) {
@@ -1195,7 +1191,8 @@ ra_rehash_server(RedisArray *ra, zval *z_redis, const char *hostname, zend_bool
11951191

11961192
/* callback */
11971193
if(z_cb && z_cb_cache) {
1198-
zval_rehash_callback(z_cb, z_cb_cache, hostname, count TSRMLS_CC);
1194+
zval_rehash_callback(z_cb, z_cb_cache, hostname, count, &z_ret TSRMLS_CC);
1195+
zval_dtor(&z_ret);
11991196
}
12001197

12011198
/* for each key, redistribute */

0 commit comments

Comments
 (0)