diff --git a/NEWS b/NEWS index 4a48ae145335c..24c1b6a15ec69 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,9 @@ PHP NEWS - DOM: . Added Dom\Element::$outerHTML. (nielsdos) +- Output: + . Fixed calculation of aligned buffer size. (cmb) + - PDO_PGSQL: . Added Iterable support for PDO::pgsqlCopyFromArray. (KentarouTakeda) . Implement GH-15387 Pdo\Pgsql::setAttribute(PDO::ATTR_PREFETCH, 0) or diff --git a/main/php_output.h b/main/php_output.h index 25a8d370707b5..55bf62f62237a 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -81,8 +81,8 @@ typedef enum _php_output_handler_hook_t { } php_output_handler_hook_t; #define PHP_OUTPUT_HANDLER_INITBUF_SIZE(s) \ -( ((s) > 1) ? \ - (s) + PHP_OUTPUT_HANDLER_ALIGNTO_SIZE - ((s) % (PHP_OUTPUT_HANDLER_ALIGNTO_SIZE)) : \ +( ((s) > 0) ? \ + ZEND_MM_ALIGNED_SIZE_EX(s, PHP_OUTPUT_HANDLER_ALIGNTO_SIZE) : \ PHP_OUTPUT_HANDLER_DEFAULT_SIZE \ ) #define PHP_OUTPUT_HANDLER_ALIGNTO_SIZE 0x1000 diff --git a/tests/output/gh16135.phpt b/tests/output/gh16135.phpt new file mode 100644 index 0000000000000..5c880ef3a2a8c --- /dev/null +++ b/tests/output/gh16135.phpt @@ -0,0 +1,27 @@ +--TEST-- +GH-16135: output buffer over-allocated for aligned chunk sizes +--FILE-- + $s["buffer_size"], ob_get_status(true))); +?> +--EXPECT-- +array(6) { + [0]=> + int(16384) + [1]=> + int(4096) + [2]=> + int(4096) + [3]=> + int(8192) + [4]=> + int(8192) + [5]=> + int(12288) +}