mirror of
https://github.com/php/php-src.git
synced 2024-09-21 09:57:23 +00:00
Fix GH-15582: Crash when not calling parent constructor of DateTimeZone
This commit is contained in:
parent
7a67fb0315
commit
f752e23cff
4
NEWS
4
NEWS
@ -2,6 +2,10 @@ PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? ????, PHP 8.2.25
|
||||
|
||||
- Date:
|
||||
. Fixed bug GH-15582: Crash when not calling parent constructor of
|
||||
DateTimeZone. (Derick)
|
||||
|
||||
- SOAP:
|
||||
. Fixed bug #62900 (Wrong namespace on xsd import error message). (nielsdos)
|
||||
|
||||
|
@ -687,8 +687,11 @@ static zend_string *date_format(const char *format, size_t format_len, timelib_t
|
||||
(offset->offset < 0) ? '-' : '+',
|
||||
abs(offset->offset / 3600),
|
||||
abs((offset->offset % 3600) / 60));
|
||||
} else {
|
||||
} else if (t->zone_type == TIMELIB_ZONETYPE_ID) {
|
||||
offset = timelib_get_time_zone_info(t->sse, t->tz_info);
|
||||
} else {
|
||||
/* Shouldn't happen, but code defensively */
|
||||
offset = timelib_time_offset_ctor();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2418,6 +2421,9 @@ PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, siz
|
||||
new_dst = tzobj->tzi.z.dst;
|
||||
new_abbr = timelib_strdup(tzobj->tzi.z.abbr);
|
||||
break;
|
||||
default:
|
||||
zend_throw_error(NULL, "The DateTimeZone object has not been correctly initialized by its constructor");
|
||||
return 0;
|
||||
}
|
||||
type = tzobj->type;
|
||||
} else if (dateobj->time->tz_info) {
|
||||
|
21
ext/date/tests/bug-gh15582.phpt
Normal file
21
ext/date/tests/bug-gh15582.phpt
Normal file
@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
Bug GH-15582: Crash when not calling parent constructor of DateTimeZone
|
||||
--FILE--
|
||||
<?php
|
||||
class MyDateTimeZone extends DateTimeZone
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
$mdtz = new MyDateTimeZone();
|
||||
$fusion = $mdtz;
|
||||
try {
|
||||
date_create("2005-07-14 22:30:41", $fusion);
|
||||
} catch (Error $e) {
|
||||
echo get_class($e), ': ', $e->getMessage(), "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Error: The DateTimeZone object has not been correctly initialized by its constructor
|
Loading…
Reference in New Issue
Block a user