Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--redis_array.c18
-rw-r--r--redis_array_impl.c3
2 files changed, 15 insertions, 6 deletions
diff --git a/redis_array.c b/redis_array.c
index ead1da2a..73dad311 100644
--- a/redis_array.c
+++ b/redis_array.c
@@ -394,7 +394,9 @@ ra_forward_call(INTERNAL_FUNCTION_PARAMETERS, RedisArray *ra, const char *cmd, i
zend_bool b_write_cmd = 0;
h_args = Z_ARRVAL_P(z_args);
- argc = zend_hash_num_elements(h_args);
+ if ((argc = zend_hash_num_elements(h_args)) == 0) {
+ RETURN_FALSE;
+ }
if(ra->z_multi_exec) {
redis_inst = ra->z_multi_exec; /* we already have the instance */
@@ -935,7 +937,9 @@ PHP_METHOD(RedisArray, mget)
/* init data structures */
h_keys = Z_ARRVAL_P(z_keys);
- argc = zend_hash_num_elements(h_keys);
+ if ((argc = zend_hash_num_elements(h_keys)) == 0) {
+ RETURN_FALSE;
+ }
argv = emalloc(argc * sizeof(zval*));
pos = emalloc(argc * sizeof(int));
@@ -1087,7 +1091,9 @@ PHP_METHOD(RedisArray, mset)
/* init data structures */
h_keys = Z_ARRVAL_P(z_keys);
- argc = zend_hash_num_elements(h_keys);
+ if ((argc = zend_hash_num_elements(h_keys)) == 0) {
+ RETURN_FALSE;
+ }
argv = emalloc(argc * sizeof(zval*));
pos = emalloc(argc * sizeof(int));
keys = emalloc(argc * sizeof(char*));
@@ -1234,7 +1240,11 @@ PHP_METHOD(RedisArray, del)
/* init data structures */
h_keys = Z_ARRVAL(z_keys);
- argc = zend_hash_num_elements(h_keys);
+ if ((argc = zend_hash_num_elements(h_keys)) == 0) {
+ if (free_zkeys) zval_dtor(&z_keys);
+ efree(z_args);
+ RETURN_FALSE;
+ }
argv = emalloc(argc * sizeof(zval*));
pos = emalloc(argc * sizeof(int));
diff --git a/redis_array_impl.c b/redis_array_impl.c
index 902831c2..0d740a0f 100644
--- a/redis_array_impl.c
+++ b/redis_array_impl.c
@@ -344,8 +344,7 @@ ra_make_array(HashTable *hosts, zval *z_fun, zval *z_dist, HashTable *hosts_prev
int i, count;
RedisArray *ra;
- if (!hosts) return NULL;
- count = zend_hash_num_elements(hosts);
+ if (!hosts || (count = zend_hash_num_elements(hosts)) == 0) return NULL;
/* create object */
ra = emalloc(sizeof(RedisArray));