Message ID | 20200904172026.28217-6-andreas.rheinhardt@gmail.com |
---|---|
State | Accepted |
Commit | ae343d6595608a21d30f34de3622937b1850e04a |
Headers | show |
Series | [FFmpeg-devel,1/6] avcodec/bink: Fix memleak upon init failure | expand |
On 9/4/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote: > The array in question can not be too large (only 26 elements), so it can > simply be put on the context. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> > --- > libavcodec/binkaudio.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) > LGTM > diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c > index f7e9a37a1b..7b5965ede1 100644 > --- a/libavcodec/binkaudio.c > +++ b/libavcodec/binkaudio.c > @@ -52,8 +52,8 @@ typedef struct BinkAudioContext { > int overlap_len; ///< overlap size (samples) > int block_size; > int num_bands; > - unsigned int *bands; > float root; > + unsigned int bands[26]; > float previous[MAX_CHANNELS][BINK_BLOCK_MAX_SIZE / 16]; ///< coeffs > from previous audio block > float quant_table[96]; > AVPacket *pkt; > @@ -122,10 +122,6 @@ static av_cold int decode_init(AVCodecContext *avctx) > if (sample_rate_half <= ff_wma_critical_freqs[s->num_bands - 1]) > break; > > - s->bands = av_malloc((s->num_bands + 1) * sizeof(*s->bands)); > - if (!s->bands) > - return AVERROR(ENOMEM); > - > /* populate bands data */ > s->bands[0] = 2; > for (i = 1; i < s->num_bands; i++) > @@ -273,7 +269,6 @@ static int decode_block(BinkAudioContext *s, float > **out, int use_dct) > static av_cold int decode_end(AVCodecContext *avctx) > { > BinkAudioContext * s = avctx->priv_data; > - av_freep(&s->bands); > if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == > AV_CODEC_ID_BINKAUDIO_RDFT) > ff_rdft_end(&s->trans.rdft); > else if (CONFIG_BINKAUDIO_DCT_DECODER) > -- > 2.20.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c index f7e9a37a1b..7b5965ede1 100644 --- a/libavcodec/binkaudio.c +++ b/libavcodec/binkaudio.c @@ -52,8 +52,8 @@ typedef struct BinkAudioContext { int overlap_len; ///< overlap size (samples) int block_size; int num_bands; - unsigned int *bands; float root; + unsigned int bands[26]; float previous[MAX_CHANNELS][BINK_BLOCK_MAX_SIZE / 16]; ///< coeffs from previous audio block float quant_table[96]; AVPacket *pkt; @@ -122,10 +122,6 @@ static av_cold int decode_init(AVCodecContext *avctx) if (sample_rate_half <= ff_wma_critical_freqs[s->num_bands - 1]) break; - s->bands = av_malloc((s->num_bands + 1) * sizeof(*s->bands)); - if (!s->bands) - return AVERROR(ENOMEM); - /* populate bands data */ s->bands[0] = 2; for (i = 1; i < s->num_bands; i++) @@ -273,7 +269,6 @@ static int decode_block(BinkAudioContext *s, float **out, int use_dct) static av_cold int decode_end(AVCodecContext *avctx) { BinkAudioContext * s = avctx->priv_data; - av_freep(&s->bands); if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == AV_CODEC_ID_BINKAUDIO_RDFT) ff_rdft_end(&s->trans.rdft); else if (CONFIG_BINKAUDIO_DCT_DECODER)
The array in question can not be too large (only 26 elements), so it can simply be put on the context. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- libavcodec/binkaudio.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)