From 1f50146e29de5628540146fbbd9421b17dc8543d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 20 Nov 2008 12:45:17 +0100 Subject: 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(). --- src/decoder/oggvorbis_plugin.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/decoder') diff --git a/src/decoder/oggvorbis_plugin.c b/src/decoder/oggvorbis_plugin.c index 5aa777065..3506e0006 100644 --- a/src/decoder/oggvorbis_plugin.c +++ b/src/decoder/oggvorbis_plugin.c @@ -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, ¤t_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; -- cgit v1.2.3