[FFmpeg-devel] [FFmpeg-cvslog] avcodec/mpeg12dec: switch to AVBufferRef buffer for a53 caption

lance.lmwang at gmail.com lance.lmwang at gmail.com
Sat Jun 27 12:01:31 EEST 2020


On Sat, Jun 27, 2020 at 10:37:31AM +0200, Paul B Mahol wrote:
> On 6/27/20, lance.lmwang at gmail.com <lance.lmwang at gmail.com> wrote:
> > On Sat, Jun 27, 2020 at 10:22:24AM +0200, Paul B Mahol wrote:
> >> On 6/27/20, lance.lmwang at gmail.com <lance.lmwang at gmail.com> wrote:
> >> > On Sat, Jun 27, 2020 at 09:47:33AM +0300, Martin Storsjö wrote:
> >> >> On Fri, 26 Jun 2020, Limin Wang wrote:
> >> >>
> >> >> > ffmpeg | branch: master | Limin Wang <lance.lmwang at gmail.com> | Sun
> >> >> > Jun
> >> >> > 21 20:57:22 2020 +0800| [a705bcd763e344fac191e157ffeddc285388b7fa] |
> >> >> > committer: Limin Wang
> >> >> >
> >> >> > avcodec/mpeg12dec: switch to AVBufferRef buffer for a53 caption
> >> >> >
> >> >> > Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> >> >> >
> >> >> > > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a705bcd763e344fac191e157ffeddc285388b7fa
> >> >> > ---
> >> >>
> >> >>
> >> >> This commit caused use of uninitialized data in fate-sub-cc-scte20,
> >> >> making
> >> >> the test nondeterministic.
> >> >
> >> > Sorry, how to reproduce the issue? I'm glad to check the issue. Before
> >> > submit the patch,
> >> > I have run and pass make fate testing.
> >> > On my testing x86_64 linux host and mac pro, I have run:
> >> >
> >> > make  fate-sub-cc-scte20  SAMPLES=../fate-suite
> >> >
> >> > no error report yet.
> >> >
> >>
> >> You will need to use valgrind.
> >
> > thanks, I have no experiment to use fate test with valgrind yet, I'll try to
> > study how to use it.
> 
> Just run same commands fate runs but under valgrind.

Thanks for the help, I have run with valgrind before, but haven't see any error yet. 

[lmwang at vpn2 ffmpeg.git]$ valgrind make fate-sub-cc-scte20  SAMPLES=../fate-suite --leak-check=full
...
This program built for x86_64-redhat-linux-gnu
Report bugs to <bug-make at gnu.org>
==3203==
==3203== HEAP SUMMARY:
==3203==     in use at exit: 99,725 bytes in 100 blocks
==3203==   total heap usage: 232 allocs, 132 frees, 113,644 bytes allocated
==3203==
==3203== LEAK SUMMARY:
==3203==    definitely lost: 0 bytes in 0 blocks
==3203==    indirectly lost: 0 bytes in 0 blocks
==3203==      possibly lost: 0 bytes in 0 blocks
==3203==    still reachable: 99,725 bytes in 100 blocks
==3203==         suppressed: 0 bytes in 0 blocks
==3203== Rerun with --leak-check=full to see details of leaked memory
==3203==
==3203== For lists of detected and suppressed errors, rerun with: -s
==3203== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

But by checking the code carefully, I have below fix, but I need know how to verify it.

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index f0f92ac..2562027 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2276,6 +2276,8 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
             if (ret >= 0) {
                 uint8_t field, cc1, cc2;
                 uint8_t *cap = s1->a53_buf_ref->data;
+
+                memset(s1->a53_buf_ref->data + old_size, 0, cc_count * UINT64_C(3));
                 for (i = 0; i < cc_count && get_bits_left(&gb) >= 26; i++) {
                     skip_bits(&gb, 2); // priority
                     field = get_bits(&gb, 2);
  

> 
> >
> >>
> >> >
> >> >>
> >> >> // Martin
> >> >>
> >> >> _______________________________________________
> >> >> ffmpeg-devel mailing list
> >> >> ffmpeg-devel at ffmpeg.org
> >> >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >> >>
> >> >> To unsubscribe, visit link above, or email
> >> >> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> >> >
> >> > --
> >> > Thanks,
> >> > Limin Wang
> >> > _______________________________________________
> >> > ffmpeg-devel mailing list
> >> > ffmpeg-devel at ffmpeg.org
> >> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >> >
> >> > To unsubscribe, visit link above, or email
> >> > ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> >> _______________________________________________
> >> ffmpeg-devel mailing list
> >> ffmpeg-devel at ffmpeg.org
> >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>
> >> To unsubscribe, visit link above, or email
> >> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> >
> > --
> > Thanks,
> > Limin Wang
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang


More information about the ffmpeg-devel mailing list