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

Steve Lhomme robux4 at ycbcr.xyz
Mon Jul 15 11:30:14 CEST 2019


On 2019-07-15 11:26, Rémi Denis-Courmont wrote:
> Hi,
> 
> Not claiming that it's wrong, but how could it not crash if FFmpeg freed a pointer to .rodata?

I think no one uses this code. Or if it crashes at the end of an encode 
people don't really care as long as they have their file.

> 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é.
> 
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list