diff options
author | Max Kellermann <mk@cm4all.com> | 2008-11-20 12:45:17 +0100 |
---|---|---|
committer | Max Kellermann <mk@cm4all.com> | 2008-11-20 12:45:17 +0100 |
commit | 1f50146e29de5628540146fbbd9421b17dc8543d (patch) | |
tree | 359042b19a3dffac1f91a080b51893a723d96e17 | |
parent | a8f69429b0a6492bdcb8b4d59a28c8ba90b45aed (diff) |
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().
-rw-r--r-- | src/decoder/oggvorbis_plugin.c | 13 |
1 files changed, 6 insertions, 7 deletions
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; |