Skip to content

Commit 519c435

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix GH-14808: Unexpected null pointer in Zend/zend_string.h with empty output buffer
2 parents 6361b39 + 89c3e03 commit 519c435

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ PHP NEWS
1616
- LibXML:
1717
. Fixed bug GH-14563 (Build failure with libxml2 v2.13.0). (nielsdos)
1818

19+
- Output:
20+
. Fixed bug GH-14808 (Unexpected null pointer in Zend/zend_string.h with
21+
empty output buffer). (nielsdos)
22+
1923
- PDO:
2024
. Fixed bug GH-14712 (Crash with PDORow access to null property).
2125
(David Carlier)

main/output.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,11 @@ PHPAPI int php_output_get_level(void)
360360
PHPAPI int php_output_get_contents(zval *p)
361361
{
362362
if (OG(active)) {
363-
ZVAL_STRINGL(p, OG(active)->buffer.data, OG(active)->buffer.used);
363+
if (OG(active)->buffer.used) {
364+
ZVAL_STRINGL(p, OG(active)->buffer.data, OG(active)->buffer.used);
365+
} else {
366+
ZVAL_EMPTY_STRING(p);
367+
}
364368
return SUCCESS;
365369
} else {
366370
ZVAL_NULL(p);

tests/output/gh14808.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
GH-14808 (Unexpected null pointer in Zend/zend_string.h with empty output buffer)
3+
--FILE--
4+
<?php
5+
var_dump($args);
6+
ob_start('ob_iconv_handler');
7+
ob_clean();
8+
var_dump(ob_get_contents());
9+
?>
10+
--EXPECTF--
11+
Warning: Undefined variable $args in %s on line %d
12+
NULL
13+
string(0) ""

0 commit comments

Comments
 (0)