]> git.sesse.net Git - ffmpeg/commit
avformat/mpeg: Don't copy or leak string in AVBPrint
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 4 Dec 2019 12:37:13 +0000 (13:37 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 5 Dec 2019 16:22:40 +0000 (17:22 +0100)
commitbc3cf2bbd320e1ade2791dca02b9ba947ca436ab
tree4cfe9db590e7c31f0e3b2a94e9e59fdbe8eca6c2
parent3f37880c05714ede6590fb32390ed991552d5115
avformat/mpeg: Don't copy or leak string in AVBPrint

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@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mpeg.c