From c45afa011e65324a60406c97fbdc7873acba07c0 Mon Sep 17 00:00:00 2001 From: David Reid Date: Sun, 18 Jul 2021 13:50:04 +1000 Subject: [PATCH] Add a pedantic fread() compatibility check to the vorbis decoder. --- extras/miniaudio_libvorbis.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extras/miniaudio_libvorbis.h b/extras/miniaudio_libvorbis.h index 80af083c..788a486f 100644 --- a/extras/miniaudio_libvorbis.h +++ b/extras/miniaudio_libvorbis.h @@ -90,6 +90,11 @@ static size_t ma_libvorbis_vf_callback__read(void* pBufferOut, size_t size, size size_t bytesToRead; size_t bytesRead; + /* For consistency with fread(). If `size` of `count` is 0, return 0 immediately without changing anything. */ + if (size == 0 || count == 0) { + return 0; + } + bytesToRead = size * count; result = pVorbis->onRead(pVorbis->pReadSeekTellUserData, pBufferOut, bytesToRead, &bytesRead);