Skip to content

Commit 602be4a

Browse files
committed
Fix: sapi_getenv: value should be initialized and not used in strlen if NULL/uninitialized
1 parent 3e128ee commit 602be4a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

main/SAPI.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ SAPI_API char *sapi_getenv(const char *name, size_t name_len)
10121012
return NULL;
10131013
}
10141014
if (sapi_module.getenv) {
1015-
char *value, *tmp = sapi_module.getenv(name, name_len);
1015+
char *value = NULL, *tmp = sapi_module.getenv(name, name_len);
10161016
if (tmp) {
10171017
value = estrdup(tmp);
10181018
#ifdef PHP_WIN32
@@ -1024,7 +1024,7 @@ SAPI_API char *sapi_getenv(const char *name, size_t name_len)
10241024
} else {
10251025
return NULL;
10261026
}
1027-
if (sapi_module.input_filter) {
1027+
if (value && sapi_module.input_filter) {
10281028
sapi_module.input_filter(PARSE_STRING, name, &value, strlen(value), NULL);
10291029
}
10301030
return value;

0 commit comments

Comments
 (0)