Okay, here is the proper fixed patch, tested via various methods:

$d1 = new DateTime;
while(1) {
// no memory leak
      $d1->modify("Tue, 10 Apr 2012 11:27:56 +0300");

// memory leak - now fixed with new patch
      $d1->modify("Tue, 10 Apr 2012 11:27:56 CST");

// no memory leak
      $d1->modify("Tue, 10 Apr 2012 11:27:56 Pacific/Chatham");
}


Attaching this second patch to the original bug report, as well as
including here.

Thanks!
--- ../php-5.4.9_orig/ext/date/php_date.c       2012-11-20 23:12:20.000000000 
-0600
+++ ext/date/php_date.c 2012-12-06 03:19:26.597301993 -0600
@@ -2763,6 +2763,25 @@
                        dateobj->time->s = 0;
                }
        }
+
+       if(tmp_time->zone_type) {
+               dateobj->time->zone_type = tmp_time->zone_type;
+               switch (tmp_time->zone_type) {
+               case TIMELIB_ZONETYPE_ID:
+                       dateobj->time->tz_info = tmp_time->tz_info;
+                       break;
+               case TIMELIB_ZONETYPE_OFFSET:
+                       dateobj->time->z = tmp_time->z;
+                       break;
+               case TIMELIB_ZONETYPE_ABBR:
+                       if(dateobj->time->tz_abbr) free(dateobj->time->tz_abbr);
+                       dateobj->time->z = tmp_time->z;
+                       dateobj->time->dst = tmp_time->dst;
+                       dateobj->time->tz_abbr = strdup(tmp_time->tz_abbr);
+                       break;
+               }
+       }
+
        timelib_time_dtor(tmp_time);
 
        timelib_update_ts(dateobj->time, NULL);
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to