Skip to content

Commit

Permalink
Fix a nullptr access after trying to replay an invalid filename (biol…
Browse files Browse the repository at this point in the history
  • Loading branch information
orempel authored Nov 30, 2023
1 parent 7320029 commit 894c6d8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/SdCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ char **SdCard_ReturnPlaylist(const char *fileName, const uint32_t _playMode) {
if (files != NULL) { // If **ptr already exists, de-allocate its memory
Log_Printf(LOGLEVEL_DEBUG, releaseMemoryOfOldPlaylist, ESP.getFreeHeap());
freeMultiCharArray(files, strtoul(files[0], NULL, 10) + 1);
files = nullptr;
Log_Printf(LOGLEVEL_DEBUG, freeMemoryAfterFree, ESP.getFreeHeap());
}

Expand Down Expand Up @@ -402,6 +403,7 @@ char **SdCard_ReturnPlaylist(const char *fileName, const uint32_t _playMode) {
Log_Println(unableToAllocateMemForPlaylist, LOGLEVEL_ERROR);
System_IndicateError();
freeMultiCharArray(files, cnt + 1);
files = nullptr;
return nullptr;
}
snprintf(files[0], 5, "%u", cnt);
Expand Down

0 comments on commit 894c6d8

Please sign in to comment.