History

avformat/wtvdec: Use smaller upper bound for buffer

Every code point in the BMP is representable with at most three bytes in UTF-8 and every code point not in the BMP takes four bytes. For each of the latter, the encoding of UTF-16 takes as many bytes; for each of the former, it takes at most 3/2 as many. Therefore one can decrease the size of the buffer allocated here.

Andreas Rheinhardt committed 3 years ago

Commit ea0a41b1 parent 78169f31 file · +1 −1Browse files

Unified · Split

libavformat/wtvdec.c+1−1
@@ -468,7 +468,7 @@ static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int ty · 467 unmodified lines
468 return;468 return;
469 }469 }
470 470
471 buf_size = FFMIN(FFMAX(2U * length, LEN_PRETTY_GUID) + 1, INT_MAX);471 buf_size = FFMIN(FFMAX(length + length / 2U, LEN_PRETTY_GUID) + 1, INT_MAX);
472 buf = av_malloc(buf_size);472 buf = av_malloc(buf_size);
473 if (!buf)473 if (!buf)
474 return;474 return;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t