Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix OSS Fuzz #61865: Undef variable in ++/-- for declared property th…
…at is unset in error handler Reorder when we assign the property value to NULL which is identical to a3a3964 Just for the declared property case instead of dynamic. Closes GH-12114
- Loading branch information
Showing
8 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
Zend/tests/in-de-crement/oss-fuzz-61865_binop_declared_property_unset_error_handler.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--TEST-- | ||
OSS Fuzz #61865: Undef variable in ++/-- for declared property that is unset in error handler | ||
--FILE-- | ||
<?php | ||
class C { | ||
public $a; | ||
function errorHandler($errno, $errstr) { | ||
unset($this->a); | ||
} | ||
} | ||
$c = new C; | ||
set_error_handler([$c,'errorHandler']); | ||
unset($c->a); | ||
$c->a += 5; | ||
var_dump($c->a); | ||
?> | ||
--EXPECT-- | ||
int(5) |
20 changes: 20 additions & 0 deletions
20
Zend/tests/in-de-crement/oss-fuzz-61865_postdec_declared_property_unset_error_handler.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
OSS Fuzz #61865: Undef variable in ++/-- for declared property that is unset in error handler | ||
--FILE-- | ||
<?php | ||
class C { | ||
public $a; | ||
function errorHandler($errno, $errstr) { | ||
unset($this->a); | ||
} | ||
} | ||
$c = new C; | ||
set_error_handler([$c,'errorHandler']); | ||
unset($c->a); | ||
$v = ($c->a--); | ||
var_dump($c->a); | ||
var_dump($v); | ||
?> | ||
--EXPECT-- | ||
NULL | ||
NULL |
20 changes: 20 additions & 0 deletions
20
Zend/tests/in-de-crement/oss-fuzz-61865_postinc_declared_property_unset_error_handler.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
OSS Fuzz #61865: Undef variable in ++/-- for declared property that is unset in error handler | ||
--FILE-- | ||
<?php | ||
class C { | ||
public $a; | ||
function errorHandler($errno, $errstr) { | ||
unset($this->a); | ||
} | ||
} | ||
$c = new C; | ||
set_error_handler([$c,'errorHandler']); | ||
unset($c->a); | ||
$v = ($c->a++); | ||
var_dump($c->a); | ||
var_dump($v); | ||
?> | ||
--EXPECT-- | ||
int(1) | ||
NULL |
18 changes: 18 additions & 0 deletions
18
Zend/tests/in-de-crement/oss-fuzz-61865_predec_declared_property_unset_error_handler.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--TEST-- | ||
OSS Fuzz #61865: Undef variable in ++/-- for declared property that is unset in error handler | ||
--FILE-- | ||
<?php | ||
class C { | ||
public $a; | ||
function errorHandler($errno, $errstr) { | ||
unset($this->a); | ||
} | ||
} | ||
$c = new C; | ||
set_error_handler([$c,'errorHandler']); | ||
unset($c->a); | ||
(--$c->a); | ||
var_dump($c->a); | ||
?> | ||
--EXPECT-- | ||
NULL |
18 changes: 18 additions & 0 deletions
18
Zend/tests/in-de-crement/oss-fuzz-61865_preinc_declared_property_unset_error_handler.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--TEST-- | ||
OSS Fuzz #61865: Undef variable in ++/-- for declared property that is unset in error handler | ||
--FILE-- | ||
<?php | ||
class C { | ||
public $a; | ||
function errorHandler($errno, $errstr) { | ||
unset($this->a); | ||
} | ||
} | ||
$c = new C; | ||
set_error_handler([$c,'errorHandler']); | ||
unset($c->a); | ||
(++$c->a); | ||
var_dump($c->a); | ||
?> | ||
--EXPECT-- | ||
int(1) |
25 changes: 25 additions & 0 deletions
25
Zend/tests/in-de-crement/unset_property_converted_to_obj_in_error_handler.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--TEST-- | ||
Unset declared property converted to object in error handler | ||
--FILE-- | ||
<?php | ||
class C { | ||
public $a; | ||
function errorHandler() { | ||
$this->a = new stdClass(); | ||
} | ||
} | ||
$c = new C; | ||
set_error_handler([$c,'errorHandler']); | ||
unset($c->a); | ||
|
||
try { | ||
(++$c->a); | ||
} catch (\TypeError $e) { | ||
echo $e->getMessage(), PHP_EOL; | ||
} | ||
var_dump($c->a); | ||
?> | ||
--EXPECT-- | ||
Cannot increment stdClass | ||
object(stdClass)#2 (0) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters