Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,9 @@ PHP_FUNCTION(putenv)
zend_argument_value_error(1, "must have a valid syntax");
RETURN_THROWS();
}
if (UNEXPECTED(EG(flags) & EG_FLAGS_IN_RESOURCE_SHUTDOWN)) {
RETURN_FALSE;
}

pe.putenv_string = zend_strndup(setting, setting_len);
if ((p = strchr(setting, '='))) {
Expand Down
17 changes: 17 additions & 0 deletions ext/standard/tests/streams/gh20656.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
GH-20656 (HashTable use-after-destroy in function table via stream wrapper magic __call() with nested redeclaration)
--FILE--
<?php
class Loader {
function stream_open() {
return true;
}
function __call($m, $a) {
$map[$obj] = putenv("LA=Gx$g_lang");
function __call($m, $a) {}
}
}
stream_wrapper_register('abc', 'Loader');
require 'abc://';
?>
--EXPECT--
Loading