File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
features/storage/kvstore/tdbstore Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -1019,7 +1019,10 @@ int TDBStore::init()
1019
1019
_size = (size_t ) -1 ;
1020
1020
1021
1021
_buff_bd = new BufferedBlockDevice (_bd);
1022
- _buff_bd->init ();
1022
+ ret = _buff_bd->init ();
1023
+ if (ret) {
1024
+ goto fail;
1025
+ }
1023
1026
1024
1027
// Underlying BD must have flash attributes, i.e. have an erase value
1025
1028
if (_bd->get_erase_value () == -1 ) {
@@ -1140,6 +1143,19 @@ int TDBStore::init()
1140
1143
_is_initialized = true ;
1141
1144
_mutex.unlock ();
1142
1145
return ret;
1146
+ fail:
1147
+ delete[] ram_table;
1148
+ delete _buff_bd;
1149
+ delete[] _work_buf;
1150
+ delete[] _key_buf;
1151
+ delete reinterpret_cast <inc_set_handle_t *>(_inc_set_handle);
1152
+ _ram_table = nullptr ;
1153
+ _buff_bd = nullptr ;
1154
+ _work_buf = nullptr ;
1155
+ _key_buf = nullptr ;
1156
+ _inc_set_handle = nullptr ;
1157
+ _mutex.unlock ();
1158
+ return ret;
1143
1159
}
1144
1160
1145
1161
int TDBStore::deinit ()
Original file line number Diff line number Diff line change @@ -61,8 +61,7 @@ class TDBStore : public KVStore {
61
61
* the available data and clean corrupted and erroneous records.
62
62
*
63
63
* @returns MBED_SUCCESS Success.
64
- * MBED_ERROR_READ_FAILED Unable to read from media.
65
- * MBED_ERROR_WRITE_FAILED Unable to write to media.
64
+ * @returns Negative error code on failure.
66
65
*/
67
66
virtual int init ();
68
67
You can’t perform that action at this time.
0 commit comments