diff --git a/NEWS b/NEWS index 5c70836ebff..a0c16ca9092 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,10 @@ PHP NEWS - LibXML: . Fixed bug GH-14563 (Build failure with libxml2 v2.13.0). (nielsdos) +- Output: + . Fixed bug GH-14808 (Unexpected null pointer in Zend/zend_string.h with + empty output buffer). (nielsdos) + - PDO: . Fixed bug GH-14712 (Crash with PDORow access to null property). (David Carlier) diff --git a/main/output.c b/main/output.c index 57a61e4b936..c2cb0ceab01 100644 --- a/main/output.c +++ b/main/output.c @@ -360,7 +360,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); diff --git a/tests/output/gh14808.phpt b/tests/output/gh14808.phpt new file mode 100644 index 00000000000..7a3f57ba51c --- /dev/null +++ b/tests/output/gh14808.phpt @@ -0,0 +1,13 @@ +--TEST-- +GH-14808 (Unexpected null pointer in Zend/zend_string.h with empty output buffer) +--FILE-- + +--EXPECTF-- +Warning: Undefined variable $args in %s on line %d +NULL +string(0) ""