From c95b95f5b7cf9346bf727e2716ed15a70423b938 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 14 Aug 2020 02:23:41 -0700 Subject: [PATCH] Check `rw` in musicclass::init() It's possible that SDL_RWFromMem could return NULL, and if this is the case, then we really shouldn't be passing it to MusicTrack(). --- desktop_version/src/Music.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index 7bc0adc7..01d72806 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -83,7 +83,14 @@ void musicclass::init() if (index >= 0 && index < musicReadBlob.max_headers) \ { \ rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index)); \ - musicTracks.push_back(MusicTrack( rw )); \ + if (rw == NULL) \ + { \ + printf("Unable to read music file header: %s\n", SDL_GetError()); \ + } \ + else \ + { \ + musicTracks.push_back(MusicTrack( rw )); \ + } \ } TRACK_NAMES