Commit f15c4281 authored by Justin Ruggles's avatar Justin Ruggles

libvorbis: do not flush libvorbis analysis if dsp state was not initialized

Fixes a segfault if init() fails before initializing the dsp state
parent 147ff24a
...@@ -52,6 +52,7 @@ typedef struct OggVorbisContext { ...@@ -52,6 +52,7 @@ typedef struct OggVorbisContext {
uint8_t buffer[BUFFER_SIZE]; /**< output packet buffer */ uint8_t buffer[BUFFER_SIZE]; /**< output packet buffer */
int buffer_index; /**< current buffer position */ int buffer_index; /**< current buffer position */
int eof; /**< end-of-file flag */ int eof; /**< end-of-file flag */
int dsp_initialized; /**< vd has been initialized */
vorbis_comment vc; /**< VorbisComment info */ vorbis_comment vc; /**< VorbisComment info */
ogg_packet op; /**< ogg packet */ ogg_packet op; /**< ogg packet */
double iblock; /**< impulse block bias option */ double iblock; /**< impulse block bias option */
...@@ -148,6 +149,7 @@ static av_cold int oggvorbis_encode_close(AVCodecContext *avctx) ...@@ -148,6 +149,7 @@ static av_cold int oggvorbis_encode_close(AVCodecContext *avctx)
OggVorbisContext *s = avctx->priv_data; OggVorbisContext *s = avctx->priv_data;
/* notify vorbisenc this is EOF */ /* notify vorbisenc this is EOF */
if (s->dsp_initialized)
vorbis_analysis_wrote(&s->vd, 0); vorbis_analysis_wrote(&s->vd, 0);
vorbis_block_clear(&s->vb); vorbis_block_clear(&s->vb);
...@@ -177,6 +179,7 @@ static av_cold int oggvorbis_encode_init(AVCodecContext *avctx) ...@@ -177,6 +179,7 @@ static av_cold int oggvorbis_encode_init(AVCodecContext *avctx)
ret = vorbis_error_to_averror(ret); ret = vorbis_error_to_averror(ret);
goto error; goto error;
} }
s->dsp_initialized = 1;
if ((ret = vorbis_block_init(&s->vd, &s->vb))) { if ((ret = vorbis_block_init(&s->vd, &s->vb))) {
ret = vorbis_error_to_averror(ret); ret = vorbis_error_to_averror(ret);
goto error; goto error;
......
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