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

Skip to content

Commit a471c87

Browse files
committed
Issue #2141
Fix segfault with session+tls
1 parent 677c9da commit a471c87

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

redis_session.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static void lock_release(RedisSock *redis_sock, redis_session_lock_status *lock_
380380
PS_OPEN_FUNC(redis)
381381
{
382382
php_url *url;
383-
zval params, *context = NULL;
383+
zval params, context, *zv;
384384
int i, j, path_len;
385385

386386
redis_pool *pool = ecalloc(1, sizeof(*pool));
@@ -425,6 +425,7 @@ PS_OPEN_FUNC(redis)
425425
return FAILURE;
426426
}
427427

428+
ZVAL_NULL(&context);
428429
/* parse parameters */
429430
if (url->query != NULL) {
430431
HashTable *ht;
@@ -450,7 +451,9 @@ PS_OPEN_FUNC(redis)
450451
REDIS_CONF_STRING_STATIC(ht, "prefix", &prefix);
451452
REDIS_CONF_AUTH_STATIC(ht, "auth", &user, &pass);
452453

453-
context = REDIS_HASH_STR_FIND_TYPE_STATIC(ht, "stream", IS_ARRAY);
454+
if ((zv = REDIS_HASH_STR_FIND_TYPE_STATIC(ht, "stream", IS_ARRAY)) != NULL) {
455+
ZVAL_ZVAL(&context, zv, 1, 0);
456+
}
454457

455458
zval_dtor(&params);
456459
}
@@ -492,9 +495,8 @@ PS_OPEN_FUNC(redis)
492495
persistent, persistent_id ? ZSTR_VAL(persistent_id) : NULL,
493496
retry_interval);
494497

495-
if (context != NULL) {
496-
redis_sock_set_stream_context(redis_sock, context);
497-
context = NULL;
498+
if (Z_TYPE(context) == IS_ARRAY) {
499+
redis_sock_set_stream_context(redis_sock, &context);
498500
}
499501

500502
redis_pool_add(pool, redis_sock, weight, db);

0 commit comments

Comments
 (0)