From fa3c1c81d548953853f4cc06f96615b0ec9007e1 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Thu, 20 Mar 2025 10:27:12 -0700 Subject: [PATCH] Fix GH-17836: zend_vm_gen.php shouldn't break on Windows line endings Closes GH-18121. --- NEWS | 4 ++++ Zend/zend_vm_gen.php | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/NEWS b/NEWS index 02365adeb64..1e426e1f4c9 100644 --- a/NEWS +++ b/NEWS @@ -53,6 +53,10 @@ PHP NEWS - Treewide: . Fixed bug GH-17736 (Assertion failure zend_reference_destroy()). (nielsdos) +- Windows: + . Fixed bug GH-17836 (zend_vm_gen.php shouldn't break on Windows line + endings). (DanielEScherzer) + 13 Mar 2025, PHP 8.3.19 - BCMath: diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php index 79b76538712..64105f5659f 100755 --- a/Zend/zend_vm_gen.php +++ b/Zend/zend_vm_gen.php @@ -2401,6 +2401,12 @@ function gen_vm($def, $skel) { $max_opcode = 0; $extra_num = 256; foreach ($in as $line) { + // Handle Windows line endings, GH-17836; since a bunch of regular + // expressions below test for a newline at the end, just update the + // ending + if (substr($line, -2) === "\r\n") { + $line = substr_replace($line, "\n", -2); + } ++$lineno; if (strpos($line,"ZEND_VM_HANDLER(") === 0 || strpos($line,"ZEND_VM_INLINE_HANDLER(") === 0 ||