From 0ebb40343bafd9f8b047c1917c91ab3611ded965 Mon Sep 17 00:00:00 2001 From: Tobias Markus Date: Mon, 23 Feb 2015 21:24:52 +0100 Subject: [PATCH] Fix for coverity #29360 --- src/audio/sound_file.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/audio/sound_file.cpp b/src/audio/sound_file.cpp index ebe7ea3e1..834aedaf4 100644 --- a/src/audio/sound_file.cpp +++ b/src/audio/sound_file.cpp @@ -83,7 +83,12 @@ std::unique_ptr load_sound_file(const std::string& filename) char magic[4]; if(PHYSFS_read(file, magic, sizeof(magic), 1) != 1) throw SoundError("Couldn't read magic, file too short"); - PHYSFS_seek(file, 0); + if (PHYSFS_seek(file, 0) == 0) { + std::stringstream msg; + msg << "Couldn't seek through sound file: " << PHYSFS_getLastError(); + throw SoundError(msg.str()); + } + if(strncmp(magic, "RIFF", 4) == 0) return std::unique_ptr(new WavSoundFile(file)); else if(strncmp(magic, "OggS", 4) == 0) -- 2.11.0