Skip to content

Commit c2bbc94

Browse files
handle init of an already initialised security db
1 parent afcbdfc commit c2bbc94

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

features/FEATURE_BLE/source/generic/GenericSecurityManager.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,20 @@ ble_error_t GenericSecurityManager::init(
4848
return err;
4949
}
5050

51+
if (_db) {
52+
delete _db;
53+
}
54+
55+
FILE* db_file = FileSecurityDb::open_db_file(db_path);
56+
57+
if (db_file) {
58+
_db = new (std::nothrow) FileSecurityDb(db_file);
59+
} else {
60+
_db = new (std::nothrow) MemorySecurityDb();
61+
}
62+
5163
if (!_db) {
52-
FILE* db_file = FileSecurityDb::open_db_file(db_path);
53-
if (db_file) {
54-
_db = new (std::nothrow) FileSecurityDb(db_file);
55-
} else {
56-
_db = new (std::nothrow) MemorySecurityDb();
57-
}
64+
return BLE_ERROR_NO_MEM;
5865
}
5966

6067
_db->restore();

0 commit comments

Comments
 (0)