Message ID | 1569031935-8967-2-git-send-email-mypopydev@gmail.com |
---|---|
State | New |
Headers | show |
On 9/20/2019 11:12 PM, Jun Zhao wrote: > From: Jun Zhao <barryjzhao@tencent.com> > > avpriv_mpeg4audio_get_config will use MPEG4AudioConfig.chan_config to get > the MPEG4AudioConfig.channels, but if we use a uninitialized variable, > we will get an indeterminate channels, add an explicit initialization > for this case. in mpeg4audio.c i'm seeing c->chan_config = get_bits(gb, 4); if (c->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) c->channels = ff_mpeg4audio_channels[c->chan_config]; First chan_config is set using bitstream data, then channels is derived from it. So not sure what you mean by uninitialized variable. > > Signed-off-by: Jun Zhao <barryjzhao@tencent.com> > --- > libavcodec/aac_adtstoasc_bsf.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/libavcodec/aac_adtstoasc_bsf.c b/libavcodec/aac_adtstoasc_bsf.c > index 6541b11..96e80b0 100644 > --- a/libavcodec/aac_adtstoasc_bsf.c > +++ b/libavcodec/aac_adtstoasc_bsf.c > @@ -133,7 +133,7 @@ static int aac_adtstoasc_init(AVBSFContext *ctx) > { > /* Validate the extradata if the stream is already MPEG-4 AudioSpecificConfig */ > if (ctx->par_in->extradata) { > - MPEG4AudioConfig mp4ac; > + MPEG4AudioConfig mp4ac = {0}; > int ret = avpriv_mpeg4audio_get_config(&mp4ac, ctx->par_in->extradata, > ctx->par_in->extradata_size * 8, 1); > if (ret < 0) { >
On 9/20/2019 11:17 PM, James Almer wrote: > On 9/20/2019 11:12 PM, Jun Zhao wrote: >> From: Jun Zhao <barryjzhao@tencent.com> >> >> avpriv_mpeg4audio_get_config will use MPEG4AudioConfig.chan_config to get >> the MPEG4AudioConfig.channels, but if we use a uninitialized variable, >> we will get an indeterminate channels, add an explicit initialization >> for this case. > > in mpeg4audio.c i'm seeing > > c->chan_config = get_bits(gb, 4); > if (c->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) > c->channels = ff_mpeg4audio_channels[c->chan_config]; > > First chan_config is set using bitstream data, then channels is derived > from it. So not sure what you mean by uninitialized variable. Right, chan_config can be higher than 8. Is channels used anywhere beyond the implicit PS check at the end of this function? We shouldn't need to zero initializing the struct on every file calling this, so perhaps that check can be improved, or channels set to 0 or some sane default within this function instead. > >> >> Signed-off-by: Jun Zhao <barryjzhao@tencent.com> >> --- >> libavcodec/aac_adtstoasc_bsf.c | 2 +- >> 1 files changed, 1 insertions(+), 1 deletions(-) >> >> diff --git a/libavcodec/aac_adtstoasc_bsf.c b/libavcodec/aac_adtstoasc_bsf.c >> index 6541b11..96e80b0 100644 >> --- a/libavcodec/aac_adtstoasc_bsf.c >> +++ b/libavcodec/aac_adtstoasc_bsf.c >> @@ -133,7 +133,7 @@ static int aac_adtstoasc_init(AVBSFContext *ctx) >> { >> /* Validate the extradata if the stream is already MPEG-4 AudioSpecificConfig */ >> if (ctx->par_in->extradata) { >> - MPEG4AudioConfig mp4ac; >> + MPEG4AudioConfig mp4ac = {0}; >> int ret = avpriv_mpeg4audio_get_config(&mp4ac, ctx->par_in->extradata, >> ctx->par_in->extradata_size * 8, 1); >> if (ret < 0) { >> >
diff --git a/libavcodec/aac_adtstoasc_bsf.c b/libavcodec/aac_adtstoasc_bsf.c index 6541b11..96e80b0 100644 --- a/libavcodec/aac_adtstoasc_bsf.c +++ b/libavcodec/aac_adtstoasc_bsf.c @@ -133,7 +133,7 @@ static int aac_adtstoasc_init(AVBSFContext *ctx) { /* Validate the extradata if the stream is already MPEG-4 AudioSpecificConfig */ if (ctx->par_in->extradata) { - MPEG4AudioConfig mp4ac; + MPEG4AudioConfig mp4ac = {0}; int ret = avpriv_mpeg4audio_get_config(&mp4ac, ctx->par_in->extradata, ctx->par_in->extradata_size * 8, 1); if (ret < 0) {