mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-03 06:20:57 +00:00
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:
parent
386e56258d
commit
17209fd330
1 changed files with 9 additions and 2 deletions
|
@ -242,6 +242,9 @@ int mp3_skiptags(snd_stream_t *stream)
|
||||||
unsigned char buf[128];
|
unsigned char buf[128];
|
||||||
long len; size_t readsize;
|
long len; size_t readsize;
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
|
/* failsafe */
|
||||||
|
long oldlength = stream->fh.length;
|
||||||
|
long oldstart = stream->fh.start;
|
||||||
|
|
||||||
readsize = FS_fread(buf, 1, 128, &stream->fh);
|
readsize = FS_fread(buf, 1, 128, &stream->fh);
|
||||||
if (!readsize || FS_ferror(&stream->fh)) goto fail;
|
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:
|
fail:
|
||||||
|
if (rc < 0) {
|
||||||
|
stream->fh.start = oldstart;
|
||||||
|
stream->fh.length = oldlength;
|
||||||
|
}
|
||||||
FS_rewind(&stream->fh);
|
FS_rewind(&stream->fh);
|
||||||
return (stream->fh.length > 0)? rc : -1;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* USE_CODEC_MP3 */
|
#endif /* USE_CODEC_MP3 */
|
||||||
|
|
Loading…
Reference in a new issue