Skip to content

Commit e3388ff

Browse files
author
Derick Rethans
committed
- MFH: Fixed bug #46889: Memory leak in strtotime().
1 parent e179d4e commit e3388ff

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ PHP NEWS
66
- Fixed security issue in imagerotate(), background colour isn't validated
77
correctly with a non truecolour image. (Fixes CVE-2008-5498) (Scott)
88

9+
- Fixed bug #46889: Memory leak in strtotime(). (Derick)
910
- Fixed bug #46798 (Crash in mssql extension when retrieving a NULL value
1011
inside a binary or image column type). (Ilia)
1112
- Fixed bug #46782 (fastcgi.c parse error). (Matt)

ext/date/lib/parse_date.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Generated by re2c 0.13.5 on Sun Oct 26 11:59:08 2008 */
1+
/* Generated by re2c 0.13.5 on Thu Dec 18 15:52:22 2008 */
22
#line 1 "ext/date/lib/parse_date.re"
33
/*
44
+----------------------------------------------------------------------+
@@ -22483,7 +22483,7 @@ timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container
2248322483

2248422484
void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options)
2248522485
{
22486-
if (!(options && TIMELIB_OVERRIDE_TIME) && parsed->have_date && !parsed->have_time) {
22486+
if (!(options & TIMELIB_OVERRIDE_TIME) && parsed->have_date && !parsed->have_time) {
2248722487
parsed->h = 0;
2248822488
parsed->i = 0;
2248922489
parsed->s = 0;
@@ -22503,7 +22503,7 @@ void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options)
2250322503
parsed->tz_abbr = now->tz_abbr ? strdup(now->tz_abbr) : NULL;
2250422504
}
2250522505
if (!parsed->tz_info) {
22506-
parsed->tz_info = now->tz_info ? timelib_tzinfo_clone(now->tz_info) : NULL;
22506+
parsed->tz_info = now->tz_info ? (!(options & TIMELIB_NO_CLONE) ? timelib_tzinfo_clone(now->tz_info) : now->tz_info) : NULL;
2250722507
}
2250822508
if (parsed->zone_type == 0 && now->zone_type != 0) {
2250922509
parsed->zone_type = now->zone_type;

ext/date/lib/parse_date.re

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container
16191619

16201620
void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options)
16211621
{
1622-
if (!(options && TIMELIB_OVERRIDE_TIME) && parsed->have_date && !parsed->have_time) {
1622+
if (!(options & TIMELIB_OVERRIDE_TIME) && parsed->have_date && !parsed->have_time) {
16231623
parsed->h = 0;
16241624
parsed->i = 0;
16251625
parsed->s = 0;
@@ -1639,7 +1639,7 @@ void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options)
16391639
parsed->tz_abbr = now->tz_abbr ? strdup(now->tz_abbr) : NULL;
16401640
}
16411641
if (!parsed->tz_info) {
1642-
parsed->tz_info = now->tz_info ? timelib_tzinfo_clone(now->tz_info) : NULL;
1642+
parsed->tz_info = now->tz_info ? (!(options & TIMELIB_NO_CLONE) ? timelib_tzinfo_clone(now->tz_info) : now->tz_info) : NULL;
16431643
}
16441644
if (parsed->zone_type == 0 && now->zone_type != 0) {
16451645
parsed->zone_type = now->zone_type;

ext/date/lib/timelib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#define TIMELIB_NONE 0x00
3030
#define TIMELIB_OVERRIDE_TIME 0x01
31+
#define TIMELIB_NO_CLONE 0x02
3132

3233
#define TIMELIB_SPECIAL_WEEKDAY 0x01
3334

ext/date/php_date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ PHP_FUNCTION(strtotime)
11431143
t = timelib_strtotime(times, time_len, &error, DATE_TIMEZONEDB);
11441144
error1 = error->error_count;
11451145
timelib_error_container_dtor(error);
1146-
timelib_fill_holes(t, now, 0);
1146+
timelib_fill_holes(t, now, TIMELIB_NO_CLONE);
11471147
timelib_update_ts(t, tzi);
11481148
ts = timelib_date_to_int(t, &error2);
11491149

0 commit comments

Comments
 (0)