Skip to content

Commit 34c02b1

Browse files
committed
Merged pull request xdebug#1031
2 parents 91d655c + 56a5da0 commit 34c02b1

File tree

3 files changed

+53
-9
lines changed

3 files changed

+53
-9
lines changed

src/lib/var_export_xml.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -411,18 +411,17 @@ static int xdebug_object_element_export_xml_node(xdebug_object_item *item_nptr,
411411
xdebug_xml_add_child(parent, node);
412412

413413
#if PHP_VERSION_ID >= 80400
414-
{
414+
if (
415+
ZEND_USER_CODE((*item)->zobj->ce->type) &&
416+
Z_TYPE_P((*item)->zv) == IS_PTR
417+
) {
415418
zend_property_info *prop_info = Z_PTR_P((*item)->zv);
416419
HashTable *props = zend_get_properties_no_lazy_init((*item)->zobj);
420+
zval *tmp_value_for_ptr = zend_symtable_str_find(props, ZSTR_VAL(prop_info->name), ZSTR_LEN(prop_info->name));
417421

418-
// IS_PTR is for properties with hooks
419-
if (Z_TYPE_P((*item)->zv) == IS_PTR) {
420-
zval *tmp_value_for_ptr = zend_symtable_str_find(props, ZSTR_VAL(prop_info->name), ZSTR_LEN(prop_info->name));
421-
422-
xdebug_var_export_xml_node(&tmp_value_for_ptr, tmp_fullname ? tmp_fullname : NULL, node, options, level + 1);
423-
} else {
424-
xdebug_var_export_xml_node(&((*item)->zv), tmp_fullname ? tmp_fullname : NULL, node, options, level + 1);
425-
}
422+
xdebug_var_export_xml_node(&tmp_value_for_ptr, tmp_fullname ? tmp_fullname : NULL, node, options, level + 1);
423+
} else {
424+
xdebug_var_export_xml_node(&((*item)->zv), tmp_fullname ? tmp_fullname : NULL, node, options, level + 1);
426425
}
427426
#else
428427
xdebug_var_export_xml_node(&((*item)->zv), tmp_fullname ? tmp_fullname : NULL, node, options, level + 1);

tests/debugger/bug02360.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
$KEEP_EOL = new DateInterval('P28D');
3+
4+
echo get_class($KEEP_EOL);
5+
?>

tests/debugger/bug02360.phpt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
Test for bug #2360: Debugging DateInterval causes a crash
3+
--SKIPIF--
4+
<?php
5+
require __DIR__ . '/../utils.inc';
6+
check_reqs('dbgp');
7+
?>
8+
--FILE--
9+
<?php
10+
require 'dbgp/dbgpclient.php';
11+
$filename = dirname(__FILE__) . '/bug02360.inc';
12+
13+
$commands = array(
14+
"breakpoint_set -t line -f file://{$filename} -n 4",
15+
'run',
16+
'context_get',
17+
'detach',
18+
);
19+
20+
dbgpRunFile( $filename, $commands );
21+
?>
22+
--EXPECTF--
23+
<?xml version="1.0" encoding="iso-8859-1"?>
24+
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file://bug02360.inc" language="PHP" xdebug:language_version="" protocol_version="1.0" appid=""><engine version=""><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2099 by Derick Rethans]]></copyright></init>
25+
26+
-> breakpoint_set -i 1 -t line -f file://bug02360.inc -n 4
27+
<?xml version="1.0" encoding="iso-8859-1"?>
28+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="1" id="{{PID}}0001"></response>
29+
30+
-> run -i 2
31+
<?xml version="1.0" encoding="iso-8859-1"?>
32+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="2" status="break" reason="ok"><xdebug:message filename="file://bug02360.inc" lineno="4"></xdebug:message></response>
33+
34+
-> context_get -i 3
35+
<?xml version="1.0" encoding="iso-8859-1"?>
36+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="3" context="0"><property name="$KEEP_EOL" fullname="$KEEP_EOL" type="object" classname="DateInterval" children="1" %s</property></response>
37+
38+
-> detach -i 4
39+
<?xml version="1.0" encoding="iso-8859-1"?>
40+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="detach" transaction_id="4" status="stopping" reason="ok"></response>

0 commit comments

Comments
 (0)