[FFmpeg-devel] [PATCH 2/3] avformat/mpeg: Don't copy or leak string in AVBPrint

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Fri Dec 6 01:10:00 EET 2019

Michael Niedermayer:
> On Wed, Dec 04, 2019 at 01:37:13PM +0100, Andreas Rheinhardt wrote:
>> vobsub_read_header() uses an AVBPrint to write a string and up until
>> now, it collected the string stored in the AVBPrint via
>> av_bprint_finalize(), which might involve an allocation and copy of the
>> string. But this is unnecessary, as the lifetime of the returned string
>> does not exceed the lifetime of the AVBPrint. So use the string in the
>> AVBPrint directly.
>> This also makes it possible to easily fix a memleak: In certain error
>> situations, the string stored in the AVBPrint would not be freed (if it
>> was dynamically allocated). This has been fixed, too.
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
>> ---
>> Supersedes https://ffmpeg.org/pipermail/ffmpeg-devel/2019-October/252074.html
>> Resending because of merge conflict.
> will apply
> thx
Thanks. During checking whether my patches work I have also found a
use of uninitialized values in vobsub_read_packet() [1]; and earlier I
have found a way to eliminate the secondary packet when reading VobSub
[2]. Could you look over them, too?

- Andreas

[1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-October/251961.html
[2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-October/251146.html

More information about the ffmpeg-devel mailing list