Skip to content

Commit 3a71724

Browse files
committed
fix(sd): Fix use after free
1 parent 70786dc commit 3a71724

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: libraries/SD/src/sd_diskio.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,10 @@ uint8_t sdcard_uninit(uint8_t pdrv) {
671671
if (pdrv >= FF_VOLUMES || card == NULL) {
672672
return 1;
673673
}
674-
AcquireSPI lock(card);
675-
sdTransaction(pdrv, GO_IDLE_STATE, 0, NULL);
674+
{
675+
AcquireSPI lock(card);
676+
sdTransaction(pdrv, GO_IDLE_STATE, 0, NULL);
677+
} // lock is destructed here
676678
ff_diskio_register(pdrv, NULL);
677679
s_cards[pdrv] = NULL;
678680
esp_err_t err = ESP_OK;

0 commit comments

Comments
 (0)