@@ -57,7 +57,10 @@ static void _php_intlgregcal_constructor_body(
57
57
zend_get_parameters_array_ex (ZEND_NUM_ARGS (), args) == FAILURE) {
58
58
intl_error_set (NULL , U_ILLEGAL_ARGUMENT_ERROR,
59
59
" intlgregcal_create_instance: too many arguments" , 0 );
60
- Z_OBJ_P (return_value) = NULL ;
60
+ if (!is_constructor) {
61
+ zval_dtor (return_value);
62
+ RETVAL_NULL ();
63
+ }
61
64
return ;
62
65
}
63
66
for (variant = ZEND_NUM_ARGS ();
@@ -67,7 +70,10 @@ static void _php_intlgregcal_constructor_body(
67
70
intl_error_set (NULL , U_ILLEGAL_ARGUMENT_ERROR,
68
71
" intlgregcal_create_instance: no variant with 4 arguments "
69
72
" (excluding trailing NULLs)" , 0 );
70
- Z_OBJ_P (return_value) = NULL ;
73
+ if (!is_constructor) {
74
+ zval_dtor (return_value);
75
+ RETVAL_NULL ();
76
+ }
71
77
return ;
72
78
}
73
79
@@ -77,7 +83,10 @@ static void _php_intlgregcal_constructor_body(
77
83
" |z!s!" , &tz_object, &locale, &locale_len) == FAILURE) {
78
84
intl_error_set (NULL , U_ILLEGAL_ARGUMENT_ERROR,
79
85
" intlgregcal_create_instance: bad arguments" , 0 );
80
- Z_OBJ_P (return_value) = NULL ;
86
+ if (!is_constructor) {
87
+ zval_dtor (return_value);
88
+ RETVAL_NULL ();
89
+ }
81
90
return ;
82
91
}
83
92
}
@@ -86,7 +95,10 @@ static void _php_intlgregcal_constructor_body(
86
95
&largs[5 ]) == FAILURE) {
87
96
intl_error_set (NULL , U_ILLEGAL_ARGUMENT_ERROR,
88
97
" intlgregcal_create_instance: bad arguments" , 0 );
89
- Z_OBJ_P (return_value) = NULL ;
98
+ if (!is_constructor) {
99
+ zval_dtor (return_value);
100
+ RETVAL_NULL ();
101
+ }
90
102
return ;
91
103
}
92
104
@@ -98,7 +110,13 @@ static void _php_intlgregcal_constructor_body(
98
110
TimeZone *tz = timezone_process_timezone_argument (tz_object, NULL ,
99
111
" intlgregcal_create_instance" );
100
112
if (tz == NULL ) {
101
- Z_OBJ_P (return_value) = NULL ;
113
+ if (!EG (exception)) {
114
+ zend_throw_exception (IntlException_ce_ptr, " Constructor failed" , 0 );
115
+ }
116
+ if (!is_constructor) {
117
+ zval_dtor (return_value);
118
+ RETVAL_NULL ();
119
+ }
102
120
return ;
103
121
}
104
122
if (!locale) {
@@ -114,7 +132,10 @@ static void _php_intlgregcal_constructor_body(
114
132
delete gcal;
115
133
}
116
134
delete tz;
117
- Z_OBJ_P (return_value) = NULL ;
135
+ if (!is_constructor) {
136
+ zval_dtor (return_value);
137
+ RETVAL_NULL ();
138
+ }
118
139
return ;
119
140
}
120
141
} else {
@@ -124,7 +145,10 @@ static void _php_intlgregcal_constructor_body(
124
145
intl_error_set (NULL , U_ILLEGAL_ARGUMENT_ERROR,
125
146
" intlgregcal_create_instance: at least one of the arguments"
126
147
" has an absolute value that is too large" , 0 );
127
- Z_OBJ_P (return_value) = NULL ;
148
+ if (!is_constructor) {
149
+ zval_dtor (return_value);
150
+ RETVAL_NULL ();
151
+ }
128
152
return ;
129
153
}
130
154
}
@@ -146,7 +170,10 @@ static void _php_intlgregcal_constructor_body(
146
170
if (gcal) {
147
171
delete gcal;
148
172
}
149
- Z_OBJ_P (return_value) = NULL ;
173
+ if (!is_constructor) {
174
+ zval_dtor (return_value);
175
+ RETVAL_NULL ();
176
+ }
150
177
return ;
151
178
}
152
179
@@ -163,7 +190,10 @@ static void _php_intlgregcal_constructor_body(
163
190
" from PHP's default timezone name (see date_default_timezone_get())" ,
164
191
0 );
165
192
delete gcal;
166
- Z_OBJ_P (return_value) = NULL ;
193
+ if (!is_constructor) {
194
+ zval_dtor (return_value);
195
+ RETVAL_NULL ();
196
+ }
167
197
return ;
168
198
}
169
199
@@ -177,18 +207,10 @@ static void _php_intlgregcal_constructor_body(
177
207
178
208
U_CFUNC PHP_FUNCTION (intlgregcal_create_instance)
179
209
{
180
- zval orig;
181
210
intl_error_reset (NULL );
182
211
183
212
object_init_ex (return_value, GregorianCalendar_ce_ptr);
184
- ZVAL_COPY_VALUE (&orig, return_value);
185
-
186
213
_php_intlgregcal_constructor_body (INTERNAL_FUNCTION_PARAM_PASSTHRU, 0 );
187
-
188
- if (Z_TYPE_P (return_value) == IS_OBJECT && Z_OBJ_P (return_value) == NULL ) {
189
- zval_dtor (&orig);
190
- RETURN_NULL ();
191
- }
192
214
}
193
215
194
216
U_CFUNC PHP_METHOD (IntlGregorianCalendar, __construct)
@@ -198,11 +220,6 @@ U_CFUNC PHP_METHOD(IntlGregorianCalendar, __construct)
198
220
zend_replace_error_handling (EH_THROW, IntlException_ce_ptr, &error_handling);
199
221
return_value = getThis ();
200
222
_php_intlgregcal_constructor_body (INTERNAL_FUNCTION_PARAM_PASSTHRU, 1 );
201
- if (Z_TYPE_P (return_value) == IS_OBJECT && Z_OBJ_P (return_value) == NULL ) {
202
- if (!EG (exception)) {
203
- zend_throw_exception (IntlException_ce_ptr, " Constructor failed" , 0 );
204
- }
205
- }
206
223
zend_restore_error_handling (&error_handling);
207
224
}
208
225
0 commit comments