Skip to content

Commit 78f0abf

Browse files
committed
Fixed crash on ZREM with missing parameter.
generic_multiple_args_cmd() checked for missing parameters but was missing a return FAILURE when the number of parameters was lower than expected. A unit test was added. This fixes GiHub issue phpredis#102.
1 parent b5be148 commit 78f0abf

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

redis.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1974,7 +1974,7 @@ PHPAPI int generic_multiple_args_cmd(INTERNAL_FUNCTION_PARAMETERS, char *keyword
19741974
RedisSock *redis_sock;
19751975

19761976
if(argc < min_argc) {
1977-
WRONG_PARAM_COUNT;
1977+
zend_wrong_param_count();
19781978
ZVAL_BOOL(return_value, 0);
19791979
return FAILURE;
19801980
}

tests/TestRedis.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2686,6 +2686,10 @@ private function checkSerializer($mode) {
26862686
$this->assertTrue(1 === $this->redis->zDelete('key', $z[3]));
26872687
$this->assertTrue(0 === $this->redis->zDelete('key', $z[3]));
26882688
unset($z[3]);
2689+
2690+
// check that zDelete doesn't crash with a missing parameter (GitHub issue #102):
2691+
$this->assertTrue(FALSE === @$this->redis->zDelete('key'));
2692+
26892693
// variadic
26902694
$this->redis->delete('k');
26912695
$this->redis->zAdd('k', 0, 'a');

0 commit comments

Comments
 (0)