From bedcc244d968b2ae3daf30d2e8ef5209d93c80d0 Mon Sep 17 00:00:00 2001 From: krcroft Date: Wed, 4 Dec 2019 20:18:52 -0800 Subject: [PATCH] STB Vorbis: Check before derefercing a potential NULL pointer --- src/libs/decoders/stb_vorbis.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libs/decoders/stb_vorbis.h b/src/libs/decoders/stb_vorbis.h index 77a7ee58..319b1d11 100644 --- a/src/libs/decoders/stb_vorbis.h +++ b/src/libs/decoders/stb_vorbis.h @@ -1333,14 +1333,20 @@ static int STBV_CDECL point_compare(const void *p, const void *q) static uint8 get8(vorb *z) { if (USE_MEMORY(z)) { - if (z->stream >= z->stream_end) { z->eof = TRUE; return 0; } + if (z->stream >= z->stream_end) { + z->eof = TRUE; + return 0; + } return *z->stream++; } #ifdef __SDL_SOUND_INTERNAL__ { uint8 c; - if (SDL_RWread(z->rwops, &c, 1, 1) != 1) { z->eof = TRUE; return 0; } + if (z->rwops == NULL || SDL_RWread(z->rwops, &c, 1, 1) != 1) { + z->eof = TRUE; + return 0; + } return c; } #endif