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

Skip to content

Commit 43e6cab

Browse files
peter15914michael-grunder
authored andcommitted
Fix potential NULL dereference
The return value of INI_STR() is always checked for NULL.
1 parent 044b303 commit 43e6cab

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

redis_session.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ static int session_gc_maxlifetime(void) {
147147
/* Retrieve redis.session.compression from php.ini */
148148
static int session_compression_type(void) {
149149
const char *compression = INI_STR("redis.session.compression");
150+
if(compression == NULL || *compression == '\0' || strncasecmp(compression, "none", sizeof("none") - 1) == 0) {
151+
return REDIS_COMPRESSION_NONE;
152+
}
153+
150154
#ifdef HAVE_REDIS_LZF
151155
if(strncasecmp(compression, "lzf", sizeof("lzf") - 1) == 0) {
152156
return REDIS_COMPRESSION_LZF;
@@ -162,9 +166,6 @@ static int session_compression_type(void) {
162166
return REDIS_COMPRESSION_LZ4;
163167
}
164168
#endif
165-
if(*compression == '\0' || strncasecmp(compression, "none", sizeof("none") - 1) == 0) {
166-
return REDIS_COMPRESSION_NONE;
167-
}
168169

169170
// E_NOTICE when outside of valid values
170171
php_error_docref(NULL, E_NOTICE, "redis.session.compression is outside of valid values, disabling");

0 commit comments

Comments
 (0)