@@ -89,48 +89,48 @@ fs_backend *fs_backend_init(const char *db_name, int flags)
8989 ret -> md = fs_metadata_open (db_name );
9090 if (!ret -> md ) {
9191 fs_error (LOG_CRIT , "cannot read metadata file for kb %s" , db_name );
92-
92+ free ( ret );
9393 return NULL ;
9494 }
9595
9696 if (!fs_metadata_get_string (ret -> md , FS_MD_NAME , NULL )) {
9797 fs_error (LOG_ERR , "no value for KB name in metadata, does KB exist?" );
98-
98+ free ( ret );
9999 return NULL ;
100100 }
101101
102102 const char * hashfunc = fs_metadata_get_string (ret -> md , FS_MD_HASHFUNC , "MD5" );
103103 if (strcmp (hashfunc , FS_HASH )) {
104104 fs_error (LOG_ERR , "stored hash function does not match server's hash function" );
105105 fs_error (LOG_ERR , "rebuild code with correct function or replace store" );
106-
106+ free ( ret );
107107 return NULL ;
108108 }
109109
110110 const char * store_type = fs_metadata_get_string (ret -> md , FS_MD_STORE , "semi-native" );
111111 if (strcmp (store_type , "native" )) {
112112 fs_error (LOG_ERR , "tried to open %s store with native backend" , store_type );
113-
113+ free ( ret );
114114 return NULL ;
115115 }
116116
117117 if (strcmp (fs_metadata_get_string (ret -> md , FS_MD_NAME , "-no-match-" ), db_name )) {
118118 fs_error (LOG_CRIT , "metadata and opened KB name don't match %s / %s" , db_name , fs_metadata_get_string (ret -> md , FS_MD_NAME , "-no-match-" ));
119-
119+ free ( ret );
120120 return NULL ;
121121 }
122122
123123 ret -> segments = fs_metadata_get_int (ret -> md , FS_MD_SEGMENTS , 0 );
124124 const int version = fs_metadata_get_int (ret -> md , FS_MD_VERSION , 0 );
125125 if (version == -1 ) {
126126 fs_error (LOG_CRIT , "cannot find number of segments in KB %s" , db_name );
127-
127+ free ( ret );
128128 return NULL ;
129129 }
130130 if (version > FS_CURRENT_TABLE_VERSION ||
131131 version < FS_EARLIEST_TABLE_VERSION ) {
132132 fs_error (LOG_ERR , "wrong table metadata version in KB %s" , db_name );
133-
133+ free ( ret );
134134 return NULL ;
135135 }
136136
0 commit comments