diff options
author | Peter Ross <pross@xvid.org> | 2013-01-08 01:48:13 +1100 |
---|---|---|
committer | Peter Ross <pross@xvid.org> | 2013-01-08 01:59:13 +1100 |
commit | a572cc8c7a0354d84156cfd1611dda8891f7c4db (patch) | |
tree | 465fa46510f913d4f2e49dda4d09705cfa387949 | |
parent | 7fb87bc5f24b1be13269109506c05e4c54695b5e (diff) | |
download | ffmpeg-a572cc8c7a0354d84156cfd1611dda8891f7c4db.tar.gz |
wtvdec: prevent memory leak in get_tag()
-rw-r--r-- | libavformat/wtvdec.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c index 3121269cf8..139d2a4f41 100644 --- a/libavformat/wtvdec.c +++ b/libavformat/wtvdec.c @@ -448,15 +448,20 @@ done: static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int type, int length) { - int buf_size = FFMAX(2*length, LEN_PRETTY_GUID) + 1; - char *buf = av_malloc(buf_size); - if (!buf) - return; + int buf_size; + char *buf; if (!strcmp(key, "WM/MediaThumbType")) { avio_skip(pb, length); return; - } else if (type == 0 && length == 4) { + } + + buf_size = FFMAX(2*length, LEN_PRETTY_GUID) + 1; + buf = av_malloc(buf_size); + if (!buf) + return; + + if (type == 0 && length == 4) { snprintf(buf, buf_size, "%"PRIi32, avio_rl32(pb)); } else if (type == 1) { avio_get_str16le(pb, length, buf, buf_size); |