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

Skip to content

Commit 92f14b1

Browse files
Fix a memory leak when regenerating IDs (#1445)
Make sure we free any existing session lock key if we're going to update it. Otherwise we will leak that memory.
1 parent eb8bcc1 commit 92f14b1

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

redis_session.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ PS_CREATE_SID_FUNC(redis)
616616
#endif
617617
}
618618

619+
if (pool->lock_status.session_key) zend_string_release(pool->lock_status.session_key);
619620
#if (PHP_MAJOR_VERSION < 7)
620621
pool->lock_status.session_key = redis_session_key(rpm, sid, strlen(sid));
621622
#else
@@ -758,6 +759,7 @@ PS_READ_FUNC(redis)
758759
}
759760

760761
/* send GET command */
762+
if (pool->lock_status.session_key) zend_string_release(pool->lock_status.session_key);
761763
pool->lock_status.session_key = redis_session_key(rpm, skey, skeylen);
762764
cmd_len = REDIS_SPPRINTF(&cmd, "GET", "S", pool->lock_status.session_key);
763765

0 commit comments

Comments
 (0)