From f39b1625afe13f921f43641feda8a1a4a54bab75 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 22 Jun 2014 10:05:27 -0700 Subject: [PATCH] Add a safety check. --- UI/BackgroundAudio.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/UI/BackgroundAudio.cpp b/UI/BackgroundAudio.cpp index 7f39edebe5..9e7c904264 100644 --- a/UI/BackgroundAudio.cpp +++ b/UI/BackgroundAudio.cpp @@ -58,7 +58,12 @@ public: if (codec == PSP_CODEC_AT3) { // The first two bytes are actually not useful part of the extradata. - file_.readData(at3_extradata, 16); + // We already read 16 bytes, so make sure there's enough left. + if (file_.getCurrentChunkSize() >= 32) { + file_.readData(at3_extradata, 16); + } else { + memset(at3_extradata, 0, sizeof(at3_extradata)); + } } file_.ascend(); // ILOG("got fmt data: %i", samplesPerSec);