snd_mp3tag.c: tidy-up return code. add a failsafe for fshandle_t.

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1660 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Ozkan Sezer 2019-12-12 14:04:01 +00:00
parent 386e56258d
commit 17209fd330

View file

@ -242,6 +242,9 @@ int mp3_skiptags(snd_stream_t *stream)
unsigned char buf[128];
long len; size_t readsize;
int rc = -1;
/* failsafe */
long oldlength = stream->fh.length;
long oldstart = stream->fh.start;
readsize = FS_fread(buf, 1, 128, &stream->fh);
if (!readsize || FS_ferror(&stream->fh)) goto fail;
@ -330,10 +333,14 @@ int mp3_skiptags(snd_stream_t *stream)
}
}
rc = 0;
rc = (stream->fh.length > 0)? 0 : -1;
fail:
if (rc < 0) {
stream->fh.start = oldstart;
stream->fh.length = oldlength;
}
FS_rewind(&stream->fh);
return (stream->fh.length > 0)? rc : -1;
return rc;
}
#endif /* USE_CODEC_MP3 */