Skip to content

Commit 3a7b002

Browse files
committed
Fixed bug #74950 (nullpointer deref in simplexml_element_getDocNamespaces)
1 parent 95d2908 commit 3a7b002

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ PHP NEWS
55
- Core:
66
. Fixed bug #74947 (Segfault in scanner on INF number). (Laruence)
77

8+
- SimpleXML:
9+
. Fixed bug #74950 (nullpointer deref in simplexml_element_getDocNamespaces).
10+
(Laruence)
11+
812
- SPL:
913
. Fixed bug #74669 (Unserialize ArrayIterator broken). (Andrew Nester)
1014

ext/simplexml/simplexml.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,16 +2321,16 @@ SXE_METHOD(__construct)
23212321
}
23222322

23232323
if (ZEND_SIZE_T_INT_OVFL(data_len)) {
2324-
php_error_docref(NULL, E_WARNING, "Data is too long");
2325-
RETURN_FALSE;
2324+
zend_throw_exception(zend_ce_exception, "Data is too long", 0);
2325+
return;
23262326
}
23272327
if (ZEND_SIZE_T_INT_OVFL(ns_len)) {
2328-
php_error_docref(NULL, E_WARNING, "Namespace is too long");
2329-
RETURN_FALSE;
2328+
zend_throw_exception(zend_ce_exception, "Namespace is too long", 0);
2329+
return;
23302330
}
23312331
if (ZEND_LONG_EXCEEDS_INT(options)) {
2332-
php_error_docref(NULL, E_WARNING, "Invalid options");
2333-
RETURN_FALSE;
2332+
zend_throw_exception(zend_ce_exception, "Invalid options", 0);
2333+
return;
23342334
}
23352335

23362336
docp = is_url ? xmlReadFile(data, NULL, (int)options) : xmlReadMemory(data, (int)data_len, NULL, NULL, (int)options);

ext/simplexml/tests/bug74950.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #74950 (null pointer deref in zim_simplexml_element_getDocNamespaces)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
6+
?>
7+
--FILE--
8+
<?php
9+
$xml=new SimpleXMLElement(0,9000000000);var_dump($xml->getDocNamespaces())?>
10+
?>
11+
--EXPECTF--
12+
Fatal error: Uncaught Exception: Invalid options in %sbug74950.php:%d
13+
Stack trace:
14+
#0 %sbug74950.php(%d): SimpleXMLElement->__construct('0', 9000000000)
15+
#1 {main}
16+
thrown in %sbug74950.php on line %d

0 commit comments

Comments
 (0)