mike            Tue Aug  1 15:55:03 2006 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/ext/date   php_date.c 
  Log:
  MFH:
   - fix leaks on multiple calls to DateTime::__construct()
   - throw exception on unparseable time strings in DateTime::__construct()
  
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.c?r1=1.43.2.45.2.21&r2=1.43.2.45.2.22&diff_format=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.43.2.45.2.21 
php-src/ext/date/php_date.c:1.43.2.45.2.22
--- php-src/ext/date/php_date.c:1.43.2.45.2.21  Tue Aug  1 13:28:28 2006
+++ php-src/ext/date/php_date.c Tue Aug  1 15:55:03 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_date.c,v 1.43.2.45.2.21 2006/08/01 13:28:28 mike Exp $ */
+/* $Id: php_date.c,v 1.43.2.45.2.22 2006/08/01 15:55:03 mike Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -1544,9 +1544,22 @@
 {
        timelib_time   *now;
        timelib_tzinfo *tzi;
+       timelib_error_container *err = NULL;
        int free_tzi = 0;
        
-       dateobj->time = timelib_strtotime(time_str_len ? time_str : "now", 
time_str_len ? time_str_len : sizeof("now") -1, NULL, DATE_TIMEZONEDB);
+       if (dateobj->time) {
+               if (dateobj->time->tz_info) {
+                       timelib_tzinfo_dtor(dateobj->time->tz_info);
+               }
+               timelib_time_dtor(dateobj->time);
+       }
+       dateobj->time = timelib_strtotime(time_str_len ? time_str : "now", 
time_str_len ? time_str_len : sizeof("now") -1, &err, DATE_TIMEZONEDB);
+       if (err) {
+               if (err->error_count) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to 
parse time string (%s)", time_str);
+               }
+               timelib_error_container_dtor(err);
+       }
 
        if (timezone_object) {
                php_timezone_obj *tzobj;
@@ -1599,8 +1612,9 @@
        int time_str_len = 0;
        
        if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO", 
&time_str, &time_str_len, &timezone_object, date_ce_timezone)) {
-               /* TODO: throw Exception on unparseable dates */
+               php_set_error_handling(EH_THROW, NULL TSRMLS_CC);
                date_initialize(zend_object_store_get_object(getThis() 
TSRMLS_CC), time_str, time_str_len, timezone_object TSRMLS_CC);
+               php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
        }
 }
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to