1
1
/*
2
- +----------------------------------------------------------------------+
2
+ +----------------------------------------------------------------------+
3
3
| Copyright (c) The PHP Group |
4
4
+----------------------------------------------------------------------+
5
5
| This source file is subject to version 3.01 of the PHP license, |
@@ -857,9 +857,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent)
857
857
}
858
858
if (!connection -> info -> lock .fp ) {
859
859
/* stream operation already wrote an error message */
860
- zend_string_release_ex (resource_key , /* persistent */ false);
861
- zval_ptr_dtor (return_value );
862
- RETURN_FALSE ;
860
+ goto fail ;
863
861
}
864
862
if (!error && !php_stream_supports_lock (connection -> info -> lock .fp )) {
865
863
error = "Stream does not support locking" ;
@@ -878,19 +876,15 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent)
878
876
}
879
877
if (!connection -> info -> fp ) {
880
878
/* stream operation already wrote an error message */
881
- zend_string_release_ex (resource_key , /* persistent */ false);
882
- zval_ptr_dtor (return_value );
883
- RETURN_FALSE ;
879
+ goto fail ;
884
880
}
885
881
if (hptr -> flags & (DBA_NO_APPEND |DBA_CAST_AS_FD )) {
886
882
/* Needed because some systems do not allow to write to the original
887
883
* file contents with O_APPEND being set.
888
884
*/
889
885
if (SUCCESS != php_stream_cast (connection -> info -> fp , PHP_STREAM_AS_FD , (void * )& connection -> info -> fd , 1 )) {
890
886
php_error_docref (NULL , E_WARNING , "Could not cast stream" );
891
- zend_string_release_ex (resource_key , /* persistent */ false);
892
- zval_ptr_dtor (return_value );
893
- RETURN_FALSE ;
887
+ goto fail ;
894
888
#ifdef F_SETFL
895
889
} else if (modenr == DBA_CREAT ) {
896
890
int flags = fcntl (connection -> info -> fd , F_GETFL );
@@ -924,9 +918,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent)
924
918
php_error_docref (NULL , E_WARNING , "Driver initialization failed for handler: %s" , hptr -> name );
925
919
}
926
920
}
927
- zend_string_release_ex (resource_key , /* persistent */ false);
928
- zval_ptr_dtor (return_value );
929
- RETURN_FALSE ;
921
+ goto fail ;
930
922
}
931
923
932
924
connection -> info -> hnd = hptr ;
@@ -935,13 +927,22 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent)
935
927
if (zend_register_persistent_resource_ex (connection -> hash , connection -> info , le_pdb ) == NULL ) {
936
928
php_error_docref (NULL , E_WARNING , "Could not register persistent resource" );
937
929
zend_string_release_ex (resource_key , /* persistent */ false);
930
+ dba_close_connection (connection );
938
931
zval_ptr_dtor (return_value );
939
932
RETURN_FALSE ;
940
933
}
941
934
}
942
935
943
936
zend_hash_add_new (& DBA_G (connections ), connection -> hash , return_value );
944
937
zend_string_release_ex (resource_key , /* persistent */ false);
938
+ return ;
939
+ fail :
940
+ zend_string_release_ex (resource_key , /* persistent */ false);
941
+ zend_string_release_ex (connection -> hash , persistent );
942
+ dba_close_info (connection -> info );
943
+ connection -> info = NULL ;
944
+ zval_ptr_dtor (return_value );
945
+ RETURN_FALSE ;
945
946
}
946
947
/* }}} */
947
948
0 commit comments