Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2099f19

Browse files
Merge branch 'hotfix/ra_mget_segfault' into develop
2 parents 58f38ae + 6418410 commit 2099f19

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

redis_array.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,6 @@ PHP_METHOD(RedisArray, mget)
849849

850850
/* calls */
851851
for(n = 0; n < ra->count; ++n) { /* for each node */
852-
853852
/* copy args for MGET call on node. */
854853
MAKE_STD_ZVAL(z_argarray);
855854
array_init(z_argarray);
@@ -873,7 +872,21 @@ PHP_METHOD(RedisArray, mget)
873872
zval_ptr_dtor(&z_argarray);
874873

875874
for(i = 0, j = 0; i < argc; ++i) {
876-
if(pos[i] != n) continue;
875+
/* Error out if we didn't get a proper response */
876+
if(Z_TYPE_P(z_ret) != IS_ARRAY) {
877+
/* cleanup */
878+
zval_dtor(z_ret);
879+
efree(z_ret);
880+
zval_ptr_dtor(&z_tmp_array);
881+
efree(pos);
882+
efree(redis_instances);
883+
efree(argc_each);
884+
885+
/* failure */
886+
RETURN_FALSE;
887+
}
888+
889+
if(pos[i] != n) continue;
877890

878891
zend_hash_quick_find(Z_ARRVAL_P(z_ret), NULL, 0, j, (void**)&z_cur);
879892
j++;
@@ -886,7 +899,6 @@ PHP_METHOD(RedisArray, mget)
886899
}
887900
zval_dtor(z_ret);
888901
efree(z_ret);
889-
890902
}
891903

892904
/* copy temp array in the right order to return_value */

0 commit comments

Comments
 (0)