summaryrefslogtreecommitdiff
path: root/ext/intl/timezone/timezone_class.cpp
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2012-05-17 23:17:00 +0200
committerGustavo André dos Santos Lopes <cataphract@php.net>2012-05-17 23:17:00 +0200
commit49b1f5819485b974b62357c02f2bb4b4d2324c09 (patch)
tree849a4cdd5029c411c21543bf6bda4754fca07b06 /ext/intl/timezone/timezone_class.cpp
parent887744f6b40946ad14b9c5f3f1b6b191a84dad6a (diff)
downloadphp-git-49b1f5819485b974b62357c02f2bb4b4d2324c09.tar.gz
Fixed a couple of memory leaks
Diffstat (limited to 'ext/intl/timezone/timezone_class.cpp')
-rw-r--r--ext/intl/timezone/timezone_class.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/ext/intl/timezone/timezone_class.cpp b/ext/intl/timezone/timezone_class.cpp
index 31893fe491..a1a9866eed 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;
}
/* }}} */