diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2014-09-03 00:22:41 +0200 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2014-09-03 21:22:59 +0200 |
commit | 235d401bfa407806a468379611bd7ed23e5cd0df (patch) | |
tree | 54afbac3b261f0c312bc2d4c122318918088f67f /libavcodec/vorbisenc.c | |
parent | fcfc90ed65efdcb51c68b230e8fdbae541f31870 (diff) | |
download | ffmpeg-235d401bfa407806a468379611bd7ed23e5cd0df.tar.gz |
vorbisenc: avoid large stack allocation.
Code is only used during initialization, so malloc/free
should be fine to use.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Diffstat (limited to 'libavcodec/vorbisenc.c')
-rw-r--r-- | libavcodec/vorbisenc.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c index 0fb7190779..0f78d95ffd 100644 --- a/libavcodec/vorbisenc.c +++ b/libavcodec/vorbisenc.c @@ -585,9 +585,11 @@ static int put_main_header(vorbis_enc_context *venc, uint8_t **out) { int i; PutBitContext pb; - uint8_t buffer[50000] = {0}, *p = buffer; - int buffer_len = sizeof buffer; int len, hlens[3]; + int buffer_len = 50000; + uint8_t *buffer = av_mallocz(buffer_len), *p = buffer; + if (!buffer) + return AVERROR(ENOMEM); // identification header init_put_bits(&pb, p, buffer_len); @@ -710,6 +712,7 @@ static int put_main_header(vorbis_enc_context *venc, uint8_t **out) buffer_len += hlens[i]; } + av_freep(&buffer); return p - *out; } |