Skip to content

Commit cf83bdd

Browse files
committed
JIT: Fix register clobbering
Fixes oss-fuzz #45590
1 parent e9fc81a commit cf83bdd

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15877,6 +15877,9 @@ static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend
1587715877
if (op1_info & MAY_BE_DOUBLE) {
1587815878
regset = ZEND_REGSET(ZREG_XMM0);
1587915879
}
15880+
if (opline->result_type != IS_UNUSED && (op1_info & MAY_BE_LONG)) {
15881+
ZEND_REGSET_INCL(regset, ZREG_R1);
15882+
}
1588015883
}
1588115884
break;
1588215885
case ZEND_ADD:
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Register Alloction 014: Register clobbering
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
function foo() {
11+
for($cnt = 0; $cnt < 6; $cnt++) {
12+
$e = $a-- + $a-- + $a *= $a;
13+
for ($i = 0; $i <= .1; $i++);
14+
}
15+
}
16+
foo();
17+
?>
18+
DONE
19+
--EXPECTF--
20+
Warning: Undefined variable $a in %sreg_alloc_014.php on line 4
21+
DONE

0 commit comments

Comments
 (0)