ogg: check the ov_read() return value before the vorbis_info evaluation

The ov_info() return value may be corrupt when ov_read() did not
return a positive value.  First check for success, then check
ov_info().
This commit is contained in:
Max Kellermann 2008-11-20 12:45:17 +01:00
parent a8f69429b0
commit 1f50146e29

View File

@ -274,6 +274,12 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
ret = ov_read(&vf, chunk, sizeof(chunk),
OGG_DECODE_USE_BIGENDIAN, 2, 1, &current_section);
if (ret == OV_HOLE) /* bad packet */
ret = 0;
else if (ret <= 0)
/* break on EOF or other error */
break;
if (current_section != prev_section) {
/*printf("new song!\n"); */
vorbis_info *vi = ov_info(&vf, -1);
@ -303,13 +309,6 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
prev_section = current_section;
if (ret <= 0) {
if (ret == OV_HOLE) /* bad packet */
ret = 0;
else /* break on EOF or other error */
break;
}
if ((test = ov_bitrate_instant(&vf)) > 0)
bitRate = test / 1000;