]> granicus.if.org Git - php/commitdiff
- Fixed bug #46889: Memory leak in strtotime().
authorDerick Rethans <derick@php.net>
Thu, 18 Dec 2008 14:54:51 +0000 (14:54 +0000)
committerDerick Rethans <derick@php.net>
Thu, 18 Dec 2008 14:54:51 +0000 (14:54 +0000)
ext/date/lib/parse_date.c
ext/date/lib/parse_date.re
ext/date/lib/timelib.h
ext/date/php_date.c

index 5df8351a5960c71ee750bc9b9d812afa41d701b9..eea15ec704de7ab8e8d3b415ef4ab7801f1cb1eb 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Wed Nov  5 11:39:34 2008 */
+/* Generated by re2c 0.13.5 on Thu Dec 18 15:50:45 2008 */
 #line 1 "ext/date/lib/parse_date.re"
 /*
    +----------------------------------------------------------------------+
@@ -24232,7 +24232,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
 
 void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options)
 {
-       if (!(options && TIMELIB_OVERRIDE_TIME) && parsed->have_date && !parsed->have_time) {
+       if (!(options & TIMELIB_OVERRIDE_TIME) && parsed->have_date && !parsed->have_time) {
                parsed->h = 0;
                parsed->i = 0;
                parsed->s = 0;
@@ -24252,7 +24252,7 @@ void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options)
                parsed->tz_abbr = now->tz_abbr ? strdup(now->tz_abbr) : NULL;
        }
        if (!parsed->tz_info) {
-               parsed->tz_info = now->tz_info ? timelib_tzinfo_clone(now->tz_info) : NULL;
+               parsed->tz_info = now->tz_info ? (!(options & TIMELIB_NO_CLONE) ? timelib_tzinfo_clone(now->tz_info) : now->tz_info) : NULL;
        }
        if (parsed->zone_type == 0 && now->zone_type != 0) {
                parsed->zone_type = now->zone_type;
index 812d16b5588efad3e7f68437e6043ed451770f83..049685dd4ab026124a63dccf83768b2ded50d140 100644 (file)
@@ -2089,7 +2089,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
 
 void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options)
 {
-       if (!(options && TIMELIB_OVERRIDE_TIME) && parsed->have_date && !parsed->have_time) {
+       if (!(options & TIMELIB_OVERRIDE_TIME) && parsed->have_date && !parsed->have_time) {
                parsed->h = 0;
                parsed->i = 0;
                parsed->s = 0;
@@ -2109,7 +2109,7 @@ void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options)
                parsed->tz_abbr = now->tz_abbr ? strdup(now->tz_abbr) : NULL;
        }
        if (!parsed->tz_info) {
-               parsed->tz_info = now->tz_info ? timelib_tzinfo_clone(now->tz_info) : NULL;
+               parsed->tz_info = now->tz_info ? (!(options & TIMELIB_NO_CLONE) ? timelib_tzinfo_clone(now->tz_info) : now->tz_info) : NULL;
        }
        if (parsed->zone_type == 0 && now->zone_type != 0) {
                parsed->zone_type = now->zone_type;
index f23978f89a181400790ddc2276564d2d790fad8d..432792349dc20474aeff12417ef2162b0439cf73 100644 (file)
@@ -28,6 +28,7 @@
 
 #define TIMELIB_NONE             0x00
 #define TIMELIB_OVERRIDE_TIME    0x01
+#define TIMELIB_NO_CLONE         0x02
 
 #define TIMELIB_SPECIAL_WEEKDAY                   0x01
 #define TIMELIB_SPECIAL_DAY_OF_WEEK_IN_MONTH      0x02
index f02abe725dc8d3f975de9ee2bc901ee4ee9634e7..950289751d29d945a4a3f99040b6bce5ff1de8dd 100644 (file)
@@ -1513,7 +1513,7 @@ PHP_FUNCTION(strtotime)
        t = timelib_strtotime(times, time_len, &error, DATE_TIMEZONEDB);
        error1 = error->error_count;
        timelib_error_container_dtor(error);
-       timelib_fill_holes(t, now, 0);
+       timelib_fill_holes(t, now, TIMELIB_NO_CLONE);
        timelib_update_ts(t, tzi);
        ts = timelib_date_to_int(t, &error2);