Skip to content

Commit

Permalink
Merge branch 'master' of github.com:xdebug/xdebug
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Jan 10, 2016
2 parents af4ea77 + dcb8a05 commit f5f8f95
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
27 changes: 27 additions & 0 deletions tests/bug01245.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
Test for bug #1245: xdebug_dump_superglobals dumps *uninitialized* with PHP 7
--INI--
xdebug.default_enable=1
xdebug.collect_params=4
html_errors=0
xdebug.dump.GET=*
xdebug.dump.POST=*
--GET--
getFoo=bar
--POST--
postBar=baz
--FILE--
<?php
trigger_error("TEST");
?>
--EXPECTF--
Notice: TEST in %sbug01245.php on line 2

Call Stack:
%w%f %w%d 1. {main}() %sbug01245.php:0
%w%f %w%d 2. trigger_error('TEST') %sbug01245.php:2

Dump $_GET
$_GET['getFoo'] = 'bar'
Dump $_POST
$_POST['postBar'] = 'baz'
21 changes: 12 additions & 9 deletions xdebug_superglobals.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ static void dump_hash_elem(zval *z, char *name, long index, char *elem, int html
}

#if PHP_VERSION_ID >= 70000
static int dump_hash_elem_va(zval *pDest, int num_args, va_list args, zend_hash_key *hash_key)
static int dump_hash_elem_va(zval *pDest, zend_ulong index, zend_string *hash_key, char *name, int html, xdebug_str *str)
{
#else
static int dump_hash_elem_va(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
#endif
{
int html;
char *name;
Expand All @@ -82,16 +82,13 @@ static int dump_hash_elem_va(void *pDest TSRMLS_DC, int num_args, va_list args,
name = va_arg(args, char *);
html = va_arg(args, int);
str = va_arg(args, xdebug_str *);

#if PHP_VERSION_ID >= 70000
if (hash_key->key) {
#else
if (hash_key->nKeyLength == 0) {
#endif

if (HASH_KEY_IS_NUMERIC(hash_key)) {
dump_hash_elem(*((zval **) pDest), name, hash_key->h, NULL, html, str TSRMLS_CC);
} else {
#if PHP_VERSION_ID >= 70000
dump_hash_elem(*((zval **) pDest), name, 0, (char *) hash_key->key->val, html, str TSRMLS_CC);
dump_hash_elem(pDest, name, 0, HASH_APPLY_KEY_VAL(hash_key), html, str TSRMLS_CC);
#else
dump_hash_elem(*((zval **) pDest), name, 0, (char *) hash_key->arKey, html, str TSRMLS_CC);
#endif
Expand All @@ -104,6 +101,9 @@ static void dump_hash(xdebug_llist *l, char *name, int name_len, int html, xdebu
{
#if PHP_VERSION_ID >= 70000
zval *z;
zend_ulong num;
zend_string *key;
zval *val;
#else
zval **z;
#endif
Expand Down Expand Up @@ -148,11 +148,14 @@ static void dump_hash(xdebug_llist *l, char *name, int name_len, int html, xdebu
#endif

if (ht && (*((char *) (elem->ptr)) == '*')) {
zend_hash_apply_with_arguments(ht TSRMLS_CC, dump_hash_elem_va, 3, name, html, str);
#if PHP_VERSION_ID >= 70000
ZEND_HASH_FOREACH_KEY_VAL_IND(ht, num, key, val) {
dump_hash_elem_va(val, num, key, name, html, str);
} ZEND_HASH_FOREACH_END();
} else if (ht && (z = zend_hash_find(ht, s))) {
dump_hash_elem(z, name, 0, elem->ptr, html, str TSRMLS_CC);
#else
zend_hash_apply_with_arguments(ht TSRMLS_CC, dump_hash_elem_va, 3, name, html, str);
} else if (ht && zend_hash_find(ht, elem->ptr, strlen(elem->ptr) + 1, (void **) &z) == SUCCESS) {
dump_hash_elem(*z, name, 0, elem->ptr, html, str TSRMLS_CC);
#endif
Expand Down

0 comments on commit f5f8f95

Please sign in to comment.