Skip to content

Fix GH-14808: Unexpected null pointer in Zend/zend_string.h with empty output buffer #14815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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
6 changes: 5 additions & 1 deletion main/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,11 @@ PHPAPI int php_output_get_level(void)
PHPAPI int php_output_get_contents(zval *p)
{
if (OG(active)) {
ZVAL_STRINGL(p, OG(active)->buffer.data, OG(active)->buffer.used);
if (OG(active)->buffer.used) {
ZVAL_STRINGL(p, OG(active)->buffer.data, OG(active)->buffer.used);
} else {
ZVAL_EMPTY_STRING(p);
}
return SUCCESS;
} else {
ZVAL_NULL(p);
Expand Down
13 changes: 13 additions & 0 deletions tests/output/gh14808.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
GH-14808 (Unexpected null pointer in Zend/zend_string.h with empty output buffer)
--FILE--
<?php
var_dump($args);
ob_start('ob_iconv_handler');
ob_clean();
var_dump(ob_get_contents());
?>
--EXPECTF--
Warning: Undefined variable $args in %s on line %d
NULL
string(0) ""
Loading