diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2012-02-28 19:51:25 -0500 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2012-02-29 14:54:23 -0500 |
commit | f15c4281dcabeddb61cb6430e0cc1047173292f8 (patch) | |
tree | 107523c766576f2d3043dbc52e27024aa23f99d4 | |
parent | 147ff24a0e8d819615a0f596df3ea47dddd79fdc (diff) | |
download | ffmpeg-f15c4281dcabeddb61cb6430e0cc1047173292f8.tar.gz |
libvorbis: do not flush libvorbis analysis if dsp state was not initialized
Fixes a segfault if init() fails before initializing the dsp state
-rw-r--r-- | libavcodec/libvorbis.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/libvorbis.c b/libavcodec/libvorbis.c index 7b44c1f671..d7839425ea 100644 --- a/libavcodec/libvorbis.c +++ b/libavcodec/libvorbis.c @@ -52,6 +52,7 @@ typedef struct OggVorbisContext { uint8_t buffer[BUFFER_SIZE]; /**< output packet buffer */ int buffer_index; /**< current buffer position */ int eof; /**< end-of-file flag */ + int dsp_initialized; /**< vd has been initialized */ vorbis_comment vc; /**< VorbisComment info */ ogg_packet op; /**< ogg packet */ double iblock; /**< impulse block bias option */ @@ -148,7 +149,8 @@ static av_cold int oggvorbis_encode_close(AVCodecContext *avctx) OggVorbisContext *s = avctx->priv_data; /* notify vorbisenc this is EOF */ - vorbis_analysis_wrote(&s->vd, 0); + if (s->dsp_initialized) + vorbis_analysis_wrote(&s->vd, 0); vorbis_block_clear(&s->vb); vorbis_dsp_clear(&s->vd); @@ -177,6 +179,7 @@ static av_cold int oggvorbis_encode_init(AVCodecContext *avctx) ret = vorbis_error_to_averror(ret); goto error; } + s->dsp_initialized = 1; if ((ret = vorbis_block_init(&s->vd, &s->vb))) { ret = vorbis_error_to_averror(ret); goto error; |