Skip to content

Commit 3c53a9f

Browse files
committed
Fixed incorrect refcountion inference for BW_NOT
BW_NOT for emtpy string returns empty string Fixes oss-fuzz #41280
1 parent f302430 commit 3c53a9f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2402,7 +2402,7 @@ static zend_always_inline int _zend_update_type_info(
24022402
case ZEND_BW_NOT:
24032403
tmp = 0;
24042404
if (t1 & MAY_BE_STRING) {
2405-
tmp |= MAY_BE_STRING | MAY_BE_RC1;
2405+
tmp |= MAY_BE_STRING | MAY_BE_RC1 | MAY_BE_RCN;
24062406
}
24072407
if (t1 & (MAY_BE_ANY-MAY_BE_STRING)) {
24082408
tmp |= MAY_BE_LONG;

ext/opcache/tests/jit/bw_not_001.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
JIT BW_NOT: 001 Incorrect refcounting inference
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
opcache.protect_memory=1
9+
--FILE--
10+
<?php
11+
$x[~"$x"]*=1;
12+
?>
13+
DONE
14+
--EXPECTF--
15+
Warning: Undefined variable $x in %sbw_not_001.php on line 2
16+
17+
Warning: Undefined variable $x in %sbw_not_001.php on line 2
18+
19+
Warning: Undefined array key "" in %sbw_not_001.php on line 2
20+
DONE

0 commit comments

Comments
 (0)