Commit 235d401b authored by Reimar Döffinger's avatar Reimar Döffinger

vorbisenc: avoid large stack allocation.

Code is only used during initialization, so malloc/free
should be fine to use.
Signed-off-by: 's avatarReimar Döffinger <Reimar.Doeffinger@gmx.de>
parent fcfc90ed
...@@ -585,9 +585,11 @@ static int put_main_header(vorbis_enc_context *venc, uint8_t **out) ...@@ -585,9 +585,11 @@ static int put_main_header(vorbis_enc_context *venc, uint8_t **out)
{ {
int i; int i;
PutBitContext pb; PutBitContext pb;
uint8_t buffer[50000] = {0}, *p = buffer;
int buffer_len = sizeof buffer;
int len, hlens[3]; int len, hlens[3];
int buffer_len = 50000;
uint8_t *buffer = av_mallocz(buffer_len), *p = buffer;
if (!buffer)
return AVERROR(ENOMEM);
// identification header // identification header
init_put_bits(&pb, p, buffer_len); init_put_bits(&pb, p, buffer_len);
...@@ -710,6 +712,7 @@ static int put_main_header(vorbis_enc_context *venc, uint8_t **out) ...@@ -710,6 +712,7 @@ static int put_main_header(vorbis_enc_context *venc, uint8_t **out)
buffer_len += hlens[i]; buffer_len += hlens[i];
} }
av_freep(&buffer);
return p - *out; return p - *out;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment