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

Skip to content

Commit 8746493

Browse files
Add back a default switch case for setoption handler
We can't use `EMPTY_SWITCH_DEFAULT_CASE` here as the underlying macro will actually panic, as it calls `ZEND_UNREACHABLE` under the hood.
1 parent dc9af52 commit 8746493

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

redis_commands.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5566,7 +5566,9 @@ void redis_setoption_handler(INTERNAL_FUNCTION_PARAMETERS,
55665566
RETURN_TRUE;
55675567
}
55685568
break;
5569-
EMPTY_SWITCH_DEFAULT_CASE()
5569+
default:
5570+
php_error_docref(NULL, E_WARNING, "Unknown option '" ZEND_LONG_FMT "'", option);
5571+
break;
55705572
}
55715573
RETURN_FALSE;
55725574
}

tests/RedisTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6985,6 +6985,11 @@ public function testCopy()
69856985
$this->assertEquals('bar', $this->redis->get('key2'));
69866986
}
69876987

6988+
/* Make sure we handle a bad option value gracefully */
6989+
public function testBadOptionValue() {
6990+
$this->assertFalse(@$this->redis->setOption(pow(2, 32), false));
6991+
}
6992+
69886993
public function testSession_regenerateSessionId_noLock_noDestroy() {
69896994
$this->setSessionHandler();
69906995
$sessionId = $this->generateSessionId();

0 commit comments

Comments
 (0)