StorageManager: fixed startup crash

this crash was caused by AP_UAVCAN_DNA_Server declaring a storage
object on the stack, which meant file was not initialised to nullptr.
This commit is contained in:
Andrew Tridgell 2023-03-11 17:44:06 +11:00
parent 7563dcd916
commit c35d1bd82e
2 changed files with 6 additions and 0 deletions

View File

@ -121,6 +121,9 @@ StorageAccess::StorageAccess(StorageManager::StorageType _type) :
{ {
// calculate available bytes // calculate available bytes
total_size = 0; total_size = 0;
#if AP_SDCARD_STORAGE_ENABLED
file = nullptr;
#endif
for (uint8_t i=0; i<STORAGE_NUM_AREAS; i++) { for (uint8_t i=0; i<STORAGE_NUM_AREAS; i++) {
const StorageManager::StorageArea &area = StorageManager::layout[i]; const StorageManager::StorageArea &area = StorageManager::layout[i];
if (area.type == type) { if (area.type == type) {

View File

@ -84,6 +84,9 @@ private:
/* /*
A StorageAccess object allows access to one type of storage A StorageAccess object allows access to one type of storage
NOTE: this object may be declared on the stack, so it will not be
zero initialised
*/ */
class StorageAccess { class StorageAccess {
public: public: