Skip to content

Commit 717730d

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #77638: var_export'ing certain class instances segfaults
2 parents 2ebf530 + 23c65a8 commit 717730d

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ PHP NEWS
2323
- PCRE:
2424
. Fixed bug #78853 (preg_match() may return integer > 1). (cmb)
2525

26+
- Standard:
27+
. Fixed bug #77638 (var_export'ing certain class instances segfaults). (cmb)
28+
2629
28 Nov 2019, PHP 7.4.0
2730

2831
- Core:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Bug #77638 (var_export'ing certain class instances segfaults)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
var_export(new COM("Scripting.Dictionary"));
10+
?>
11+
--EXPECT--
12+
com::__set_state(array(
13+
))
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Bug #77638 (var_export'ing certain class instances segfaults)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('ffi')) die('skip ffi extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
var_export(FFI::new('int'));
10+
?>
11+
--EXPECT--
12+
FFI\CData::__set_state(array(
13+
))

ext/standard/var.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf) /* {{{ */
557557
zend_release_properties(myht);
558558
return;
559559
} else {
560-
GC_PROTECT_RECURSION(myht);
560+
GC_TRY_PROTECT_RECURSION(myht);
561561
}
562562
}
563563
if (level > 1) {
@@ -577,7 +577,7 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf) /* {{{ */
577577
ZEND_HASH_FOREACH_KEY_VAL_IND(myht, index, key, val) {
578578
php_object_element_export(val, index, key, level, buf);
579579
} ZEND_HASH_FOREACH_END();
580-
GC_UNPROTECT_RECURSION(myht);
580+
GC_TRY_UNPROTECT_RECURSION(myht);
581581
zend_release_properties(myht);
582582
}
583583
if (level > 1) {

0 commit comments

Comments
 (0)