Commit:    49b1f5819485b974b62357c02f2bb4b4d2324c09
Author:    Gustavo André dos Santos Lopes <cataphr...@php.net>         Thu, 17 
May 2012 23:17:00 +0200
Parents:   887744f6b40946ad14b9c5f3f1b6b191a84dad6a
Branches:  master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=49b1f5819485b974b62357c02f2bb4b4d2324c09

Log:
Fixed a couple of memory leaks

Changed paths:
  M  ext/intl/timezone/timezone_class.cpp


Diff:
diff --git a/ext/intl/timezone/timezone_class.cpp 
b/ext/intl/timezone/timezone_class.cpp
index 31893fe..a1a9866 100644
--- a/ext/intl/timezone/timezone_class.cpp
+++ b/ext/intl/timezone/timezone_class.cpp
@@ -93,7 +93,7 @@ U_CFUNC TimeZone *timezone_convert_datetimezone(int type,
                        }
 
                        id = offset_id;
-                       id_len = spprintf((char**)&id, sizeof(offset_id), 
"GMT%+03d:%02d",
+                       id_len = slprintf((char*)id, sizeof(offset_id), 
"GMT%+03d:%02d",
                                hours, minutes);
                        break;
                }
@@ -137,6 +137,7 @@ U_CFUNC zval *timezone_convert_to_datetimezone(const 
TimeZone *timeZone,
        UnicodeString           id;
        char                            *message = NULL;
        php_timezone_obj        *tzobj;
+       zval                            arg = zval_used_for_init;
 
        timeZone->getID(id);
        if (id.isBogus()) {
@@ -159,7 +160,6 @@ U_CFUNC zval *timezone_convert_to_datetimezone(const 
TimeZone *timeZone,
                tzobj->tzi.utc_offset = -1 * timeZone->getRawOffset() / (60 * 
1000);
        } else {
                /* Call the constructor! */
-               zval arg = zval_used_for_init;
                Z_TYPE(arg) = IS_STRING;
                if (intl_charFromString(id, &Z_STRVAL(arg), &Z_STRLEN(arg),
                                &INTL_ERROR_CODE(*outside_error)) == FAILURE) {
@@ -180,16 +180,21 @@ U_CFUNC zval *timezone_convert_to_datetimezone(const 
TimeZone *timeZone,
                }
        }
 
-       return ret;
-
+       if (0) {
 error:
+               if (ret) {
+                       zval_ptr_dtor(&ret);
+               }
+               ret = NULL;
+       }
+
        if (message) {
                efree(message);
        }
-       if (ret) {
-               zval_ptr_dtor(&ret);
+       if (Z_TYPE(arg) == IS_STRING) {
+               zval_dtor(&arg);
        }
-       return NULL;
+       return ret;
 }
 /* }}} */


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

Reply via email to