Skip to content

Commit 698ac23

Browse files
committed
Fixed NAN handling in SCCP
Fixes oss-fuzz #43341
1 parent 71d6501 commit 698ac23

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

ext/opcache/Optimizer/sccp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ static void set_value(scdf_ctx *scdf, sccp_ctx *ctx, int var, zval *new) {
183183
}
184184

185185
#if ZEND_DEBUG
186-
ZEND_ASSERT(zend_is_identical(value, new));
186+
ZEND_ASSERT(zend_is_identical(value, new) ||
187+
(Z_TYPE_P(value) == IS_DOUBLE && Z_TYPE_P(new) == IS_DOUBLE && isnan(Z_DVAL_P(value)) && isnan(Z_DVAL_P(new))));
187188
#endif
188189
}
189190

ext/opcache/tests/opt/sccp_036.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
SCCP 036: NAN handling
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--FILE--
8+
<?php
9+
function foo() {
10+
$y=NAN;
11+
for(;x;)for(;$y=1;);
12+
}
13+
?>
14+
DONE
15+
--EXPECT--
16+
DONE

0 commit comments

Comments
 (0)