diff options
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | ext/date/php_date.c | 49 | ||||
-rw-r--r-- | ext/date/tests/bug69587.phpt | 15 | ||||
-rw-r--r-- | ext/xml/compat.c | 7 | ||||
-rw-r--r-- | ext/xml/tests/bug73135.phpt | 24 |
5 files changed, 98 insertions, 1 deletions
@@ -19,6 +19,9 @@ PHP NEWS . Implemented FR #72768 (Add ENABLE_VIRTUAL_TERMINAL_PROCESSING flag for php.exe). (Michele Locati) +- Date: + . Fixed bug #69587 (DateInterval properties and isset). (jhdxr) + - EXIF: . Added support for vendor specific tags for the following formats: Samsung, DJI, Panasonic, Sony, Pentax, Minolta & Sigma/Foveon. (Kalle) @@ -65,4 +68,3 @@ PHP NEWS . Use Zend MM for allocation in bundled libxmlrpc (Joe) <<< NOTE: Insert NEWS from last stable release here prior to actual release! >>> - diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 67805c1f02..cbe6e91347 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -1982,6 +1982,54 @@ static int implement_date_interface_handler(zend_class_entry *interface, zend_cl return SUCCESS; } /* }}} */ +static int date_interval_has_property(zval *object, zval *member, int type, void **cache_slot) /* {{{ */ +{ + php_interval_obj *obj; + zval tmp_member; + zval rv; + zval *prop; + int retval = 0; + + if (Z_TYPE_P(member) != IS_STRING) { + ZVAL_COPY(&tmp_member, member); + convert_to_string(&tmp_member); + member = &tmp_member; + cache_slot = NULL; + } + + obj = Z_PHPINTERVAL_P(object); + + if (!obj->initialized) { + retval = (zend_get_std_object_handlers())->has_property(object, member, type, cache_slot); + if (member == &tmp_member) { + zval_dtor(member); + } + return retval; + } + + prop = date_interval_read_property(object, member, type, cache_slot, &rv); + + if (prop != NULL) { + if (type == 2) { + retval = 1; + } else if (type == 1) { + retval = zend_is_true(prop); + } else if (type == 0) { + retval = (Z_TYPE(*prop) != IS_NULL); + } + } else { + retval = (zend_get_std_object_handlers())->has_property(object, member, type, cache_slot); + } + + if (member == &tmp_member) { + zval_dtor(member); + } + + return retval; + +} +/* }}} */ + static void date_register_classes(void) /* {{{ */ { zend_class_entry ce_date, ce_immutable, ce_timezone, ce_interval, ce_period, ce_interface; @@ -2063,6 +2111,7 @@ static void date_register_classes(void) /* {{{ */ date_object_handlers_interval.offset = XtOffsetOf(php_interval_obj, std); date_object_handlers_interval.free_obj = date_object_free_storage_interval; date_object_handlers_interval.clone_obj = date_object_clone_interval; + date_object_handlers_interval.has_property = date_interval_has_property; date_object_handlers_interval.read_property = date_interval_read_property; date_object_handlers_interval.write_property = date_interval_write_property; date_object_handlers_interval.get_properties = date_object_get_properties_interval; diff --git a/ext/date/tests/bug69587.phpt b/ext/date/tests/bug69587.phpt new file mode 100644 index 0000000000..fd8b2364da --- /dev/null +++ b/ext/date/tests/bug69587.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #69587 (DateInterval properties and isset) +--FILE-- +<?php +$datetime1 = new DateTime('2009-10-11'); +$datetime2 = new DateTime('2009-10-13'); +$interval = $datetime1->diff($datetime2); + +var_dump(property_exists($interval, 'm'), isset($interval->m), empty($interval->m), empty($interval->d)); +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(false) diff --git a/ext/xml/compat.c b/ext/xml/compat.c index 0bb7b28410..30b9ff3030 100644 --- a/ext/xml/compat.c +++ b/ext/xml/compat.c @@ -593,12 +593,19 @@ has been defined and none can be detected */ } #endif + if (parser->parser->lastError.level >= XML_ERR_WARNING) { + return 0; + } + error = xmlParseChunk(parser->parser, (char *) data, data_len, is_final); if (error) { +<<<<<<< HEAD return 0; } else { return 1; } else if (parser->parser->lastError.level > XML_ERR_WARNING ){ +======= +>>>>>>> PHP-7.1 return 0; } else { return 1; diff --git a/ext/xml/tests/bug73135.phpt b/ext/xml/tests/bug73135.phpt new file mode 100644 index 0000000000..5fb43e91db --- /dev/null +++ b/ext/xml/tests/bug73135.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #73135 (xml_parse() segmentation fault) +--CREDITS-- +edgarsandi - <edgar.r.sandi@gmail.com> +--FILE-- +<?php + function start_elem($parser, $xml) { + xml_parse($parser, $xml); + } + + $xml = <<<HERE + <a xmlns="ahihi"> + <bar foo="ahihi"/> + </a> +HERE; + + $parser = xml_parser_create_ns(); + xml_set_element_handler($parser, 'start_elem', 'ahihi'); + xml_parse($parser, $xml); +?> +--EXPECTF-- +Warning: xml_parse(): Unable to call handler ahihi() in %s%ebug73135.php on line %d + +Warning: xml_parse(): Unable to call handler ahihi() in %s%ebug73135.php on line %d
\ No newline at end of file |