@@ -394,7 +394,9 @@ ra_forward_call(INTERNAL_FUNCTION_PARAMETERS, RedisArray *ra, const char *cmd, i
394394 zend_bool b_write_cmd = 0 ;
395395
396396 h_args = Z_ARRVAL_P (z_args );
397- argc = zend_hash_num_elements (h_args );
397+ if ((argc = zend_hash_num_elements (h_args )) == 0 ) {
398+ RETURN_FALSE ;
399+ }
398400
399401 if (ra -> z_multi_exec ) {
400402 redis_inst = ra -> z_multi_exec ; /* we already have the instance */
@@ -935,7 +937,9 @@ PHP_METHOD(RedisArray, mget)
935937
936938 /* init data structures */
937939 h_keys = Z_ARRVAL_P (z_keys );
938- argc = zend_hash_num_elements (h_keys );
940+ if ((argc = zend_hash_num_elements (h_keys )) == 0 ) {
941+ RETURN_FALSE ;
942+ }
939943 argv = emalloc (argc * sizeof (zval * ));
940944 pos = emalloc (argc * sizeof (int ));
941945
@@ -1087,7 +1091,9 @@ PHP_METHOD(RedisArray, mset)
10871091
10881092 /* init data structures */
10891093 h_keys = Z_ARRVAL_P (z_keys );
1090- argc = zend_hash_num_elements (h_keys );
1094+ if ((argc = zend_hash_num_elements (h_keys )) == 0 ) {
1095+ RETURN_FALSE ;
1096+ }
10911097 argv = emalloc (argc * sizeof (zval * ));
10921098 pos = emalloc (argc * sizeof (int ));
10931099 keys = emalloc (argc * sizeof (char * ));
@@ -1234,7 +1240,11 @@ PHP_METHOD(RedisArray, del)
12341240
12351241 /* init data structures */
12361242 h_keys = Z_ARRVAL (z_keys );
1237- argc = zend_hash_num_elements (h_keys );
1243+ if ((argc = zend_hash_num_elements (h_keys )) == 0 ) {
1244+ if (free_zkeys ) zval_dtor (& z_keys );
1245+ efree (z_args );
1246+ RETURN_FALSE ;
1247+ }
12381248 argv = emalloc (argc * sizeof (zval * ));
12391249 pos = emalloc (argc * sizeof (int ));
12401250
0 commit comments