Skip to content

Commit e255889

Browse files
committed
Merge branch 'PHP-8.3'
2 parents 32d6785 + 9ebdbe2 commit e255889

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

ext/date/php_date.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,11 @@ static zend_string *date_format(const char *format, size_t format_len, timelib_t
702702
(offset->offset < 0) ? '-' : '+',
703703
abs(offset->offset / 3600),
704704
abs((offset->offset % 3600) / 60));
705-
} else {
705+
} else if (t->zone_type == TIMELIB_ZONETYPE_ID) {
706706
offset = timelib_get_time_zone_info(t->sse, t->tz_info);
707+
} else {
708+
/* Shouldn't happen, but code defensively */
709+
offset = timelib_time_offset_ctor();
707710
}
708711
}
709712

@@ -2455,6 +2458,9 @@ PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, siz
24552458
new_dst = tzobj->tzi.z.dst;
24562459
new_abbr = timelib_strdup(tzobj->tzi.z.abbr);
24572460
break;
2461+
default:
2462+
zend_throw_error(NULL, "The DateTimeZone object has not been correctly initialized by its constructor");
2463+
return 0;
24582464
}
24592465
type = tzobj->type;
24602466
} else if (dateobj->time->tz_info) {

ext/date/tests/bug-gh15582.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug GH-15582: Crash when not calling parent constructor of DateTimeZone
3+
--FILE--
4+
<?php
5+
class MyDateTimeZone extends DateTimeZone
6+
{
7+
function __construct()
8+
{
9+
}
10+
}
11+
12+
$mdtz = new MyDateTimeZone();
13+
$fusion = $mdtz;
14+
try {
15+
date_create("2005-07-14 22:30:41", $fusion);
16+
} catch (Error $e) {
17+
echo get_class($e), ': ', $e->getMessage(), "\n";
18+
}
19+
?>
20+
--EXPECT--
21+
Error: The DateTimeZone object has not been correctly initialized by its constructor

0 commit comments

Comments
 (0)