Skip to content

Commit 4ab0ba6

Browse files
Fix crash on SD.end() without initial SD.begin() (#2222)
Fixes #2220
1 parent eb0badd commit 4ab0ba6

File tree

1 file changed

+3
-2
lines changed
  • libraries/SD/src

1 file changed

+3
-2
lines changed

libraries/SD/src/SD.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ class SDClass {
4343

4444
void end(bool endSPI = true) {
4545
SDFS.end();
46-
if (endSPI) {
46+
if (endSPI && _spi) {
4747
_spi->end();
48+
_spi = nullptr;
4849
}
4950
}
5051

@@ -205,7 +206,7 @@ class SDClass {
205206
return time(nullptr);
206207
}
207208

208-
HardwareSPI *_spi;
209+
HardwareSPI *_spi = nullptr;
209210
};
210211

211212

0 commit comments

Comments
 (0)