Steven Liu:
> 
> 
>> 2020年3月26日 下午9:57,lance.lmw...@gmail.com 写道:
>>
>> From: Limin Wang <lance.lmw...@gmail.com>
>>
>> Signed-off-by: Limin Wang <lance.lmw...@gmail.com>
>> ---
>> libavformat/hlsenc.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index d7b9c0e20a..694dab42dd 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -2950,13 +2950,11 @@ static int hls_init(AVFormatContext *s)
>>                 if (ret < 0)
>>                     goto fail;
>>             } else {
>> -                vs->vtt_m3u8_name = av_malloc(vtt_basename_size);
>> +                vs->vtt_m3u8_name = av_asprintf("%s_vtt.m3u8", 
>> vs->vtt_basename);
> As mkver suggestion, perhaps use bprint is better, is it?

The situation here is completely different: The lifetime of the strings
for which I used an AVBPrint was just a part of a function call, ergo it
can be replaced with a buffer on the stack (if the string is small
enough). But the lifetime of vs->vtt_m3u8_name extends beyond
hls_init(), ergo it can't be put on the stack (as is implicitly done
when using an AVBPrint). It needs to be allocated on the heap.

- Andreas
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to