[vlc-devel] [vlc-commits] avcodec: encoder: fix MPEG4 matrix passed as const

Rémi Denis-Courmont remi at remlab.net
Mon Jul 15 11:26:12 CEST 2019


Hi,

Not claiming that it's wrong, but how could it not crash if FFmpeg freed a pointer to .rodata?

Le 15 juillet 2019 10:22:35 GMT+03:00, Steve Lhomme <git at videolan.org> a écrit :
>vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Jul 10
>08:23:45 2019 +0200| [d86c4c87aa78130a4fd00294e25df865d0e2b327] |
>committer: Steve Lhomme
>
>avcodec: encoder: fix MPEG4 matrix passed as const
>
>lavc expects a pointer that it will free in avcodec_free_context().
>
>>
>http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d86c4c87aa78130a4fd00294e25df865d0e2b327
>---
>
> modules/codec/avcodec/encoder.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
>diff --git a/modules/codec/avcodec/encoder.c
>b/modules/codec/avcodec/encoder.c
>index cbac0d3394..2564e0a518 100644
>--- a/modules/codec/avcodec/encoder.c
>+++ b/modules/codec/avcodec/encoder.c
>@@ -580,8 +580,14 @@ int InitVideoEnc( vlc_object_t *p_this )
> 
>         if ( p_sys->b_mpeg4_matrix )
>         {
>-            p_context->intra_matrix = mpeg4_default_intra_matrix;
>-            p_context->inter_matrix = mpeg4_default_non_intra_matrix;
>+            p_context->intra_matrix = av_malloc(
>sizeof(mpeg4_default_intra_matrix) );
>+            if ( p_context->intra_matrix )
>+                memcpy( p_context->intra_matrix,
>mpeg4_default_intra_matrix,
>+                        sizeof(mpeg4_default_intra_matrix));
>+            p_context->inter_matrix = av_malloc(
>sizeof(mpeg4_default_non_intra_matrix) );
>+            if ( p_context->inter_matrix )
>+                memcpy( p_context->inter_matrix,
>mpeg4_default_non_intra_matrix,
>+                        sizeof(mpeg4_default_non_intra_matrix));
>         }
> 
>         if ( p_sys->b_pre_me )
>
>_______________________________________________
>vlc-commits mailing list
>vlc-commits at videolan.org
>https://mailman.videolan.org/listinfo/vlc-commits

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190715/e879658b/attachment.html>


More information about the vlc-devel mailing list