@@ -153,22 +153,10 @@ PHP_FUNCTION(finfo_open)
153
153
} else if (file && * file ) { /* user specified file, perform open_basedir checks */
154
154
155
155
if (php_check_open_basedir (file )) {
156
- if (object ) {
157
- zend_restore_error_handling (& zeh );
158
- if (!EG (exception )) {
159
- zend_throw_exception (NULL , "Constructor failed" , 0 );
160
- }
161
- }
162
- RETURN_FALSE ;
156
+ goto err ;
163
157
}
164
158
if (!expand_filepath_with_mode (file , resolved_path , NULL , 0 , CWD_EXPAND )) {
165
- if (object ) {
166
- zend_restore_error_handling (& zeh );
167
- if (!EG (exception )) {
168
- zend_throw_exception (NULL , "Constructor failed" , 0 );
169
- }
170
- }
171
- RETURN_FALSE ;
159
+ goto err ;
172
160
}
173
161
file = resolved_path ;
174
162
}
@@ -177,37 +165,35 @@ PHP_FUNCTION(finfo_open)
177
165
178
166
if (magic == NULL ) {
179
167
php_error_docref (NULL , E_WARNING , "Invalid mode '" ZEND_LONG_FMT "'." , options );
180
- if (object ) {
181
- zend_restore_error_handling (& zeh );
182
- if (!EG (exception )) {
183
- zend_throw_exception (NULL , "Constructor failed" , 0 );
184
- }
185
- }
186
- RETURN_FALSE ;
168
+ goto err ;
187
169
}
188
170
189
171
if (magic_load (magic , file ) == -1 ) {
190
172
php_error_docref (NULL , E_WARNING , "Failed to load magic database at \"%s\"" , file );
191
173
magic_close (magic );
192
- if (object ) {
193
- zend_restore_error_handling (& zeh );
194
- if (!EG (exception )) {
195
- zend_throw_exception (NULL , "Constructor failed" , 0 );
196
- }
197
- }
198
- RETURN_FALSE ;
174
+ goto err ;
199
175
}
200
176
201
177
if (object ) {
202
178
zend_restore_error_handling (& zeh );
203
179
finfo_object * obj = Z_FINFO_P (object );
204
180
obj -> magic = magic ;
181
+ return ;
205
182
} else {
206
183
zend_object * zobj = finfo_objects_new (finfo_class_entry );
207
184
finfo_object * obj = php_finfo_fetch_object (zobj );
208
185
obj -> magic = magic ;
209
186
RETURN_OBJ (zobj );
210
187
}
188
+
189
+ err :
190
+ if (object ) {
191
+ zend_restore_error_handling (& zeh );
192
+ if (!EG (exception )) {
193
+ zend_throw_exception (NULL , "Constructor failed" , 0 );
194
+ }
195
+ }
196
+ RETURN_FALSE ;
211
197
}
212
198
/* }}} */
213
199
0 commit comments