Skip to content

Commit 89f1152

Browse files
committed
Merge branch 'xdebug_3_4'
2 parents b226739 + c306a61 commit 89f1152

File tree

5 files changed

+84
-4
lines changed

5 files changed

+84
-4
lines changed

src/lib/lib.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,19 +342,19 @@ const char *xdebug_lib_find_in_globals(const char *element, const char **found_i
342342

343343
/* Elements in Superglobal Symbols */
344344
st = zend_hash_str_find_deref(&EG(symbol_table), "_GET", strlen("_GET"));
345-
if (st && (trigger_val = zend_hash_str_find_deref(Z_ARRVAL_P(st), element, strlen(element))) != NULL) {
345+
if (st && Z_TYPE_P(st) == IS_ARRAY && (trigger_val = zend_hash_str_find_deref(Z_ARRVAL_P(st), element, strlen(element))) != NULL) {
346346
*found_in_global = "GET";
347347
return Z_STRVAL_P(trigger_val);
348348
}
349349

350350
st = zend_hash_str_find_deref(&EG(symbol_table), "_POST", strlen("_POST"));
351-
if (st && (trigger_val = zend_hash_str_find_deref(Z_ARRVAL_P(st), element, strlen(element))) != NULL) {
351+
if (st && Z_TYPE_P(st) == IS_ARRAY && (trigger_val = zend_hash_str_find_deref(Z_ARRVAL_P(st), element, strlen(element))) != NULL) {
352352
*found_in_global = "POST";
353353
return Z_STRVAL_P(trigger_val);
354354
}
355355

356356
st = zend_hash_str_find_deref(&EG(symbol_table), "_COOKIE", strlen("_COOKIE"));
357-
if (st && (trigger_val = zend_hash_str_find_deref(Z_ARRVAL_P(st), element, strlen(element))) != NULL) {
357+
if (st && Z_TYPE_P(st) == IS_ARRAY && (trigger_val = zend_hash_str_find_deref(Z_ARRVAL_P(st), element, strlen(element))) != NULL) {
358358
*found_in_global = "COOKIE";
359359
return Z_STRVAL_P(trigger_val);
360360
}
@@ -382,7 +382,7 @@ const char *xdebug_lib_find_in_globals(const char *element, const char **found_i
382382
}
383383

384384
st = zend_hash_str_find_deref(&EG(symbol_table), "_ENV", strlen("_ENV"));
385-
if (st && (trigger_val = zend_hash_str_find_deref(Z_ARRVAL_P(st), element, strlen(element))) != NULL) {
385+
if (st && Z_TYPE_P(st) == IS_ARRAY && (trigger_val = zend_hash_str_find_deref(Z_ARRVAL_P(st), element, strlen(element))) != NULL) {
386386
*found_in_global = "ENV";
387387
return Z_STRVAL_P(trigger_val);
388388
}

tests/base/bug02321-001.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Test for bug #2321: Seg fault when null is assigned to $_POST
3+
--INI--
4+
xdebug.mode=develop,trace
5+
--FILE--
6+
<?php
7+
echo "bla";
8+
$_POST = NULL;
9+
10+
set_exception_handler(static function () {
11+
echo '1';
12+
});
13+
14+
require_once '_non_existing_file';
15+
?>
16+
--EXPECTF--
17+
bla
18+
Warning: require_once(_non_existing_file): Failed to open stream: No such file or directory in %sbug02321-001.php on line %d
19+
%A
20+
1

tests/base/bug02321-002.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Test for bug #2321: Seg fault when null is assigned to $_GET
3+
--INI--
4+
xdebug.mode=develop,trace
5+
--FILE--
6+
<?php
7+
echo "bla";
8+
$_GET = NULL;
9+
10+
set_exception_handler(static function () {
11+
echo '1';
12+
});
13+
14+
require_once '_non_existing_file';
15+
?>
16+
--EXPECTF--
17+
bla
18+
Warning: require_once(_non_existing_file): Failed to open stream: No such file or directory in %sbug02321-002.php on line %d
19+
%A
20+
1

tests/base/bug02321-003.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Test for bug #2321: Seg fault when null is assigned to $_COOKIE
3+
--INI--
4+
xdebug.mode=develop,trace
5+
--FILE--
6+
<?php
7+
echo "bla";
8+
$_COOKIE = NULL;
9+
10+
set_exception_handler(static function () {
11+
echo '1';
12+
});
13+
14+
require_once '_non_existing_file';
15+
?>
16+
--EXPECTF--
17+
bla
18+
Warning: require_once(_non_existing_file): Failed to open stream: No such file or directory in %sbug02321-003.php on line %d
19+
%A
20+
1

tests/base/bug02321-004.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Test for bug #2321: Seg fault when null is assigned to $_ENV
3+
--INI--
4+
xdebug.mode=develop,trace
5+
--FILE--
6+
<?php
7+
echo "bla";
8+
$_ENV = NULL;
9+
10+
set_exception_handler(static function () {
11+
echo '1';
12+
});
13+
14+
require_once '_non_existing_file';
15+
?>
16+
--EXPECTF--
17+
bla
18+
Warning: require_once(_non_existing_file): Failed to open stream: No such file or directory in %sbug02321-004.php on line %d
19+
%A
20+
1

0 commit comments

Comments
 (0)