[FFmpeg-devel] [PATCHv3 3/6] dvbsubdec: always return the whole buffer as consumed bytes

Marton Balint cus at passwd.hu
Sun Oct 6 21:14:12 CEST 2013


We don't want leftover junk bytes to be accidentally feeded to us again. Also
show the number of skipped bytes in the debug output.

Signed-off-by: Marton Balint <cus at passwd.hu>
---
 libavcodec/dvbsubdec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index 4ce40aa..9754179 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -1538,7 +1538,10 @@ static int dvbsub_decode(AVCodecContext *avctx,
     if (got_segment == 15 && sub)
         *data_size = dvbsub_display_end_segment(avctx, p, 0, sub);
 
-    return p - buf;
+    if (p - buf < buf_size)
+        av_log(avctx, AV_LOG_DEBUG, "skipping %d leftover junk bytes\n", buf_size - (int)(p - buf));
+
+    return buf_size;
 }
 
 
-- 
1.8.1.4



More information about the ffmpeg-devel mailing list