From 365ad1207a358a55a497b6987dc2773bb20888f0 Mon Sep 17 00:00:00 2001 From: hawk Date: Thu, 12 Feb 2009 15:12:54 +0000 Subject: [PATCH] - fix for bug #46889, memory leak in strtotime() Changed files: php-strtotime-memleak.patch -> 1.1 --- php-strtotime-memleak.patch | 98 +++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 php-strtotime-memleak.patch diff --git a/php-strtotime-memleak.patch b/php-strtotime-memleak.patch new file mode 100644 index 0000000..9f6ab1b --- /dev/null +++ b/php-strtotime-memleak.patch @@ -0,0 +1,98 @@ +diff -urN php-5.2.8/ext/date/lib/parse_date.c php5.2-200902121330/ext/date/lib/parse_date.c +--- php-5.2.8/ext/date/lib/parse_date.c 2008-12-07 20:31:16.000000000 +0100 ++++ php5.2-200902121330/ext/date/lib/parse_date.c 2009-02-12 14:51:26.000000000 +0100 +@@ -22395,7 +22395,7 @@ + + 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; +@@ -22415,7 +22415,7 @@ + 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; +diff -urN php-5.2.8/ext/date/lib/parse_date.c.orig php5.2-200902121330/ext/date/lib/parse_date.c.orig +--- php-5.2.8/ext/date/lib/parse_date.c.orig 2008-12-07 20:31:16.000000000 +0100 ++++ php5.2-200902121330/ext/date/lib/parse_date.c.orig 2009-02-12 14:51:26.000000000 +0100 +@@ -22483,7 +22483,7 @@ + + 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; +@@ -22503,7 +22503,7 @@ + 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; +diff -urN php-5.2.8/ext/date/lib/parse_date.re php5.2-200902121330/ext/date/lib/parse_date.re +--- php-5.2.8/ext/date/lib/parse_date.re 2008-10-26 12:27:32.000000000 +0100 ++++ php5.2-200902121330/ext/date/lib/parse_date.re 2008-12-18 16:43:49.000000000 +0100 +@@ -1619,7 +1619,7 @@ + + 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; +@@ -1639,7 +1639,7 @@ + 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; +diff -urN php-5.2.8/ext/date/lib/timelib.h php5.2-200902121330/ext/date/lib/timelib.h +--- php-5.2.8/ext/date/lib/timelib.h 2008-02-22 10:48:18.000000000 +0100 ++++ php5.2-200902121330/ext/date/lib/timelib.h 2008-12-31 12:46:14.000000000 +0100 +@@ -28,6 +28,7 @@ + + #define TIMELIB_NONE 0x00 + #define TIMELIB_OVERRIDE_TIME 0x01 ++#define TIMELIB_NO_CLONE 0x02 + + #define TIMELIB_SPECIAL_WEEKDAY 0x01 + +diff -urN php-5.2.8/ext/date/lib/timelib_structs.h php5.2-200902121330/ext/date/lib/timelib_structs.h +--- php-5.2.8/ext/date/lib/timelib_structs.h 2007-12-31 08:20:05.000000000 +0100 ++++ php5.2-200902121330/ext/date/lib/timelib_structs.h 2008-12-31 12:46:14.000000000 +0100 +@@ -16,7 +16,7 @@ + #ifndef __TIMELIB_STRUCTS_H__ + #define __TIMELIB_STRUCTS_H__ + +-#include ++#include "timelib_config.h" + + #ifdef HAVE_SYS_TYPES_H + #include +diff -urN php-5.2.8/ext/date/php_date.c php5.2-200902121330/ext/date/php_date.c +--- php-5.2.8/ext/date/php_date.c 2008-12-02 19:01:57.000000000 +0100 ++++ php5.2-200902121330/ext/date/php_date.c 2008-12-31 12:46:14.000000000 +0100 +@@ -1143,7 +1143,7 @@ + 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); + -- 2.44.0