mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix GH-15908 and GH-15026: leak / assertion failure in streams.c
This commit is contained in:
commit
94c2ae616b
3 changed files with 45 additions and 0 deletions
4
NEWS
4
NEWS
|
@ -20,6 +20,10 @@ PHP NEWS
|
|||
. Fixed bug GH-15918 (Assertion failure in ext/spl/spl_fixedarray.c).
|
||||
(nielsdos)
|
||||
|
||||
- Streams:
|
||||
. Fixed bugs GH-15908 and GH-15026 (leak / assertion failure in streams.c).
|
||||
(nielsdos)
|
||||
|
||||
12 Sep 2024, PHP 8.3.12
|
||||
|
||||
- Core:
|
||||
|
|
38
ext/standard/tests/streams/gh15908.phpt
Normal file
38
ext/standard/tests/streams/gh15908.phpt
Normal file
|
@ -0,0 +1,38 @@
|
|||
--TEST--
|
||||
GH-15908 (leak / assertion failure in streams.c)
|
||||
--CREDITS--
|
||||
YuanchengJiang
|
||||
LuMingYinDetect
|
||||
--FILE--
|
||||
<?php
|
||||
class TestStream {
|
||||
public $context;
|
||||
private $s = 0;
|
||||
function stream_open($path, $mode, $options, &$opened_path) {
|
||||
return true;
|
||||
}
|
||||
function stream_read($count) {
|
||||
echo "Read done\n";
|
||||
if ($this->s++ == 0)
|
||||
return "a\nbb\ncc";
|
||||
return "";
|
||||
}
|
||||
function stream_eof() {
|
||||
return $this->s >= 2;
|
||||
}
|
||||
}
|
||||
touch(__DIR__."/gh15908.tmp");
|
||||
stream_wrapper_register("test", "TestStream");
|
||||
$f = fopen("test://", "r");
|
||||
try {
|
||||
file_put_contents(__DIR__."/gh15908.tmp", $f, FILE_USE_INCLUDE_PATH, $f);
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
@unlink(__DIR__."/gh15908.tmp");
|
||||
?>
|
||||
--EXPECT--
|
||||
file_put_contents(): supplied resource is not a valid Stream-Context resource
|
|
@ -2211,6 +2211,9 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
|
|||
options &= ~USE_PATH;
|
||||
}
|
||||
if (EG(exception)) {
|
||||
if (resolved_path) {
|
||||
zend_string_release_ex(resolved_path, false);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue