[FFmpeg-devel] [PATCH] libavformat/ffmetadec: use dynamic allocation for line buffer

François Revol revol at free.fr
Thu Nov 8 22:47:28 EET 2018


Hi,

Le 08/11/2018 à 20:50, Michael Niedermayer a écrit :
>> +    line = av_malloc(line_size);
>> +    if (!line)
>> +        return AVERROR(ENOMEM);
> 
> this would use alot of memory for large files, also avio_size() will not
> work with all inputs

Yes I thought so as well, that was a quick fix for a friend in need.

> using av_fast_realloc() or similar should avoid both issues

You mean, having get_line() reallocate 1kB more each time it runs out
without finding a \n?

Btw, I noticed there was an avio_get_line() which was quite similar,
maybe those could be merged?


> 
>>  
>>      while(!avio_feof(s->pb)) {
>> -        get_line(s->pb, line, sizeof(line));
>> +        get_line(s->pb, line, line_size);
>>  
> 
>>          if (!memcmp(line, ID_STREAM, strlen(ID_STREAM))) {
> 
> out of memory access can happen here

Right. Preallocating at least 1kB would fix it though.


François.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20181108/4dee3b3b/attachment.sig>


More information about the ffmpeg-devel mailing list