@@ -153,22 +153,10 @@ PHP_FUNCTION(finfo_open)
153153 } else if (file && * file ) { /* user specified file, perform open_basedir checks */
154154
155155 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 ;
163157 }
164158 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 ;
172160 }
173161 file = resolved_path ;
174162 }
@@ -177,37 +165,35 @@ PHP_FUNCTION(finfo_open)
177165
178166 if (magic == NULL ) {
179167 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 ;
187169 }
188170
189171 if (magic_load (magic , file ) == -1 ) {
190172 php_error_docref (NULL , E_WARNING , "Failed to load magic database at \"%s\"" , file );
191173 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 ;
199175 }
200176
201177 if (object ) {
202178 zend_restore_error_handling (& zeh );
203179 finfo_object * obj = Z_FINFO_P (object );
204180 obj -> magic = magic ;
181+ return ;
205182 } else {
206183 zend_object * zobj = finfo_objects_new (finfo_class_entry );
207184 finfo_object * obj = php_finfo_fetch_object (zobj );
208185 obj -> magic = magic ;
209186 RETURN_OBJ (zobj );
210187 }
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 ;
211197}
212198/* }}} */
213199
0 commit comments