summaryrefslogtreecommitdiff
path: root/doc/protocols.texi
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-07-13 19:31:46 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-07-18 18:18:41 +0200
commit1998d1d6af98f31e9ddeead4893efad8144357be (patch)
treee18d1ddbc26c5366accedd8c73bb6a04b2d3a4a6 /doc/protocols.texi
parentc2e17e8d8446abbd5dcfebab1e63024837677ca7 (diff)
avformat/au: Avoid allocation for metadata string
When there are potentially annotation (i.e. metadata) fields to write, au_get_annotations() is called to produce a string with them. To do so, it uses an AVBPrint which is finalized to create the string. This is wasteful, because it always leads to an allocation even if the string actually fits into the internal buffer of the AVBPrint. This commit changes this by making au_get_annotations() modify an AVBPrint that resides on the stack of the caller (i.e. of au_write_header()). Furthermore, the AVBPrint is now checked for truncation; limiting the allocations implicit in the AVBPrint allowed to offload the overflow checks. Notice that these were not correct before: The size parameter of avio_write() is an int, yet the string in the AVBPrint was allowed to grow bigger than INT_MAX. And if the length of the string was so near UINT_MAX that the length + 32 overflowed, the old code would write the first eight bytes of the string and nothing more, leading to an invalid file. Finally, the special case in which the metadata dictionary of the AVFormatContext is empty (in which case one still has to write eight binary zeroes) is now no longer treated specially, because this case no longer incurs any allocation. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'doc/protocols.texi')
0 files changed, 0 insertions, 0 deletions