[FFmpeg-devel] [PATCH] avformat/concat: finalize the AVBprint buffer immediately

Marton Balint cus at passwd.hu
Tue Jul 27 11:12:16 EEST 2021



On Mon, 26 Jul 2021, James Almer wrote:

> On 7/26/2021 6:49 PM, Marton Balint wrote:
>> 
>> 
>> On Mon, 26 Jul 2021, James Almer wrote:
>> 
>>> Don't attempt to read its contents in place.
>>> Fixes invalid reads when run under Valgrind.
>> 
>> As far as I remember AVBPrint buffer CAN be read in place by design, zero 
>> terminator is always guaranteed, not only after finalizing. So this should 
>> not be needed. What is causing the invalid reads exactly?
>> 
>> Thanks,
>> Marton
>
> It happens only when you use a URI string that doesn't end with a line break. 
> I just noticed that after this patch some invalid reads still happen in any 
> case.
>
> I think i found out the culprit, and the following seems to fix it:
>
>> diff --git a/libavformat/concat.c b/libavformat/concat.c
>> index aec1f52d8e..94917840c6 100644
>> --- a/libavformat/concat.c
>> +++ b/libavformat/concat.c
>> @@ -251,7 +251,7 @@ static av_cold int concatf_open(URLContext *h, const 
>> char *uri, int flags)
>>              err = AVERROR(ENOMEM);
>>              break;
>>          }
>> -        cursor++;
>> +        if (*cursor) cursor++;

Yeah, I suspected the same. So this seems to be the correct patch to 
apply.

Thanks,
Marton

>>
>>          if (++len == SIZE_MAX / sizeof(*nodes)) {
>>              av_free(node_uri);
>
> Basically, av_get_token() returns a pointer to the terminating character, so 
> cursor++ for the next loop when said character was \0 was wrong.
> _______________________________________________
> 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".
>


More information about the ffmpeg-devel mailing list