@@ -133,7 +133,7 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone,
133
133
const char *func)
134
134
{
135
135
zval local_zv_tz;
136
- TimeZone * timeZone;
136
+ std::unique_ptr< TimeZone> timeZone;
137
137
138
138
if (zv_timezone == NULL || Z_TYPE_P (zv_timezone) == IS_NULL) {
139
139
timelib_tzinfo *tzinfo = get_timezone_info ();
@@ -153,12 +153,13 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone,
153
153
zval_ptr_dtor_str (&local_zv_tz);
154
154
return NULL ;
155
155
}
156
- timeZone = to->utimezone ->clone ();
157
- if (UNEXPECTED (timeZone == NULL )) {
156
+ auto tmp = to->utimezone ->clone ();
157
+ if (UNEXPECTED (tmp == NULL )) {
158
158
zend_throw_error (IntlException_ce_ptr, " %s: could not clone TimeZone" , func);
159
159
zval_ptr_dtor_str (&local_zv_tz);
160
160
return NULL ;
161
161
}
162
+ timeZone = std::unique_ptr<TimeZone>(tmp);
162
163
} else if (Z_TYPE_P (zv_timezone) == IS_OBJECT &&
163
164
instanceof_function (Z_OBJCE_P (zv_timezone), php_date_get_timezone_ce ())) {
164
165
@@ -181,24 +182,25 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone,
181
182
zval_ptr_dtor_str (&local_zv_tz);
182
183
return NULL ;
183
184
}
184
- timeZone = TimeZone::createTimeZone (id);
185
- if (UNEXPECTED (timeZone == NULL )) {
185
+ auto tmp = TimeZone::createTimeZone (id);
186
+ if (UNEXPECTED (tmp == NULL )) {
186
187
zend_throw_error (IntlException_ce_ptr, " %s: Could not create time zone" , func);
187
188
zval_ptr_dtor_str (&local_zv_tz);
188
189
return NULL ;
189
190
}
191
+ timeZone = std::unique_ptr<TimeZone>(tmp);
190
192
if (*timeZone == TimeZone::getUnknown ()) {
191
193
zend_throw_error (IntlException_ce_ptr, " %s: No such time zone: '%s'" ,
192
194
func, Z_STRVAL_P (zv_timezone));
193
195
zval_ptr_dtor_str (&local_zv_tz);
194
- delete timeZone;
195
196
return NULL ;
196
197
}
197
198
}
198
199
199
200
zval_ptr_dtor_str (&local_zv_tz);
200
201
201
- return timeZone;
202
+ // well, this is included by the centralized C intl part so the "smart" part can't go further
203
+ return timeZone.release ();
202
204
}
203
205
/* }}} */
204
206
0 commit comments