Skip to content

Commit

Permalink
Fix crash on SD.end() without initial SD.begin() (#2222)
Browse files Browse the repository at this point in the history
Fixes #2220
  • Loading branch information
earlephilhower committed Jun 11, 2024
1 parent eb0badd commit 4ab0ba6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libraries/SD/src/SD.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ class SDClass {

void end(bool endSPI = true) {
SDFS.end();
if (endSPI) {
if (endSPI && _spi) {
_spi->end();
_spi = nullptr;
}
}

Expand Down Expand Up @@ -205,7 +206,7 @@ class SDClass {
return time(nullptr);
}

HardwareSPI *_spi;
HardwareSPI *_spi = nullptr;
};


Expand Down

0 comments on commit 4ab0ba6

Please sign in to comment.