Skip to content

Commit

Permalink
Merged pull request xdebug#982
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Oct 8, 2024
2 parents ad5d739 + 087e7e5 commit cc1d461
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/var_export_html.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void xdebug_var_export_html(zval **struc, xdebug_str *str, int level, int debug_
} ZEND_HASH_FOREACH_END();

xdebug_zend_hash_apply_protection_end(myht);
} else if (myht->nNumOfElements > 0) {
} else if (myht && myht->nNumOfElements > 0) {
xdebug_str_add_fmt(str, "%*s...\n", (level * 4) - 2, "");
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/var_export_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ static void xdebug_var_export_text_ansi(zval **struc, xdebug_str *str, int mode,
} ZEND_HASH_FOREACH_END();

xdebug_zend_hash_apply_protection_end(myht);
} else if (myht->nNumOfElements > 0) {
} else if (myht && myht->nNumOfElements > 0) {
xdebug_str_add_fmt(str, "%*s...\n", (level * 2), "");
}
xdebug_str_add_fmt(str, "%*s}", (level * 2) - 2, "");
Expand Down
5 changes: 5 additions & 0 deletions tests/base/bug02020.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
--TEST--
Test for bug #2020: segfault if xdebug.dump.GET=* and integer key without value in URL
--SKIPIF--
<?php
require __DIR__ . '/../utils.inc';
check_reqs('!win');
?>
--INI--
xdebug.dump.GET=*
xdebug.mode=develop
Expand Down
51 changes: 51 additions & 0 deletions tests/base/bug02295.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
--TEST--
Test for bug #2295: var_dump(SensitiveParameterValue) segfaults
--INI--
xdebug.mode=develop
--SKIPIF--
<?php
require __DIR__ . '/../utils.inc';
check_reqs('PHP >= 8.2');
?>
--FILE--
<?php

function sp(#[SensitiveParameter] string $str): void
{
var_dump($str);
}

function spv(SensitiveParameterValue $spv): void
{
var_dump($spv);
}

ini_set('html_errors', 0);
sp('a'); // ok
spv(new SensitiveParameterValue('p'));

ini_set('xdebug.cli_color', 2);
sp('a'); // ok
spv(new SensitiveParameterValue('p'));

ini_set('html_errors', 1);
sp('a'); // ok
spv(new SensitiveParameterValue('p'));
?>
--EXPECTF--
%sbug02295.php:5:
string(1) "a"
%sbug02295.php:10:
class SensitiveParameterValue#%d (0) {
}
%sbug02295.php:5:
string(1) "a"
%sbug02295.php:10:
class SensitiveParameterValue#1 (0) {
}
<pre class='xdebug-var-dump' dir='ltr'>
<small>%sbug02295.php:5:</small><small>string</small> <font color='#cc0000'>'a'</font> <i>(length=1)</i>
</pre><pre class='xdebug-var-dump' dir='ltr'>
<small>%sbug02295.php:10:</small>
<b>object</b>(<i>SensitiveParameterValue</i>)[<i>1</i>]
</pre>

0 comments on commit cc1d461

Please sign in to comment.