Skip to content

Commit 55bf020

Browse files
committed
Fix segfault
1 parent ee210f8 commit 55bf020

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

library.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2581,7 +2581,9 @@ redis_sock_set_stream_context(RedisSock *redis_sock, zval *options)
25812581
redis_sock->stream_ctx = php_stream_context_alloc();
25822582

25832583
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(options), zkey, z_ele) {
2584-
php_stream_context_set_option(redis_sock->stream_ctx, "ssl", ZSTR_VAL(zkey), z_ele);
2584+
if (zkey != NULL) {
2585+
php_stream_context_set_option(redis_sock->stream_ctx, "ssl", ZSTR_VAL(zkey), z_ele);
2586+
}
25852587
} ZEND_HASH_FOREACH_END();
25862588

25872589
return SUCCESS;

redis.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,9 @@ PHP_METHOD(Redis, __construct)
606606
redis->sock = redis_sock_create("127.0.0.1", 0, 6379, 0, 0, 0, NULL, 0);
607607

608608
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(opts), zkey, val) {
609+
if (zkey == NULL) {
610+
continue;
611+
}
609612
ZVAL_DEREF(val);
610613
if (zend_string_equals_literal_ci(zkey, "host")) {
611614
if (Z_TYPE_P(val) != IS_STRING) {

0 commit comments

Comments
 (0)