Re: [FFmpeg-devel] [PATCH] lavc/psymodel: check for av_malloc failure
On Thu, Mar 10, 2016 at 4:10 PM, Benoit Fouetwrote: > Hi, > > Le 04/03/2016 04:06, Ganesh Ajjanagadde a écrit : >> >> No idea why in commit 01ecb7172b684f1c4b3e748f95c5a9a494ca36ec the >> checks were removed; this can lead to NULL pointer dereferences. This >> effectively reverts that portion of the commit. >> >> Signed-off-by: Ganesh Ajjanagadde >> --- >> libavcodec/psymodel.c | 6 +- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c >> index 6274a49..edc5ac8 100644 >> --- a/libavcodec/psymodel.c >> +++ b/libavcodec/psymodel.c >> @@ -120,7 +120,11 @@ av_cold struct FFPsyPreprocessContext* >> ff_psy_preprocess_init(AVCodecContext *av >>FF_FILTER_MODE_LOWPASS, >> FILT_ORDER, >>cutoff_coeff, 0.0, >> 0.0); >> if (ctx->fcoeffs) { >> -ctx->fstate = av_mallocz(sizeof(ctx->fstate[0]) * >> avctx->channels); >> +ctx->fstate = av_mallocz_array(sizeof(ctx->fstate[0]), >> avctx->channels); >> +if (!ctx->fstate) { >> +av_free(ctx); >> +return NULL; > > > you're leaking ctx->fcoeffs locally changed, thanks. > >> +} >> for (i = 0; i < avctx->channels; i++) >> ctx->fstate[i] = ff_iir_filter_init_state(FILT_ORDER); >> } > > > -- > Ben > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavc/psymodel: check for av_malloc failure
Hi, Le 04/03/2016 04:06, Ganesh Ajjanagadde a écrit : No idea why in commit 01ecb7172b684f1c4b3e748f95c5a9a494ca36ec the checks were removed; this can lead to NULL pointer dereferences. This effectively reverts that portion of the commit. Signed-off-by: Ganesh Ajjanagadde--- libavcodec/psymodel.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c index 6274a49..edc5ac8 100644 --- a/libavcodec/psymodel.c +++ b/libavcodec/psymodel.c @@ -120,7 +120,11 @@ av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *av FF_FILTER_MODE_LOWPASS, FILT_ORDER, cutoff_coeff, 0.0, 0.0); if (ctx->fcoeffs) { -ctx->fstate = av_mallocz(sizeof(ctx->fstate[0]) * avctx->channels); +ctx->fstate = av_mallocz_array(sizeof(ctx->fstate[0]), avctx->channels); +if (!ctx->fstate) { +av_free(ctx); +return NULL; you're leaking ctx->fcoeffs +} for (i = 0; i < avctx->channels; i++) ctx->fstate[i] = ff_iir_filter_init_state(FILT_ORDER); } -- Ben ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavc/psymodel: check for av_malloc failure
On Thu, Mar 3, 2016 at 10:06 PM, Ganesh Ajjanagaddewrote: > No idea why in commit 01ecb7172b684f1c4b3e748f95c5a9a494ca36ec the > checks were removed; this can lead to NULL pointer dereferences. This > effectively reverts that portion of the commit. > > Signed-off-by: Ganesh Ajjanagadde > --- > libavcodec/psymodel.c | 6 +- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c > index 6274a49..edc5ac8 100644 > --- a/libavcodec/psymodel.c > +++ b/libavcodec/psymodel.c > @@ -120,7 +120,11 @@ av_cold struct FFPsyPreprocessContext* > ff_psy_preprocess_init(AVCodecContext *av > FF_FILTER_MODE_LOWPASS, > FILT_ORDER, > cutoff_coeff, 0.0, 0.0); > if (ctx->fcoeffs) { > -ctx->fstate = av_mallocz(sizeof(ctx->fstate[0]) * > avctx->channels); > +ctx->fstate = av_mallocz_array(sizeof(ctx->fstate[0]), > avctx->channels); > +if (!ctx->fstate) { > +av_free(ctx); > +return NULL; > +} > for (i = 0; i < avctx->channels; i++) > ctx->fstate[i] = ff_iir_filter_init_state(FILT_ORDER); > } > -- > 2.7.2 > ping ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] lavc/psymodel: check for av_malloc failure
No idea why in commit 01ecb7172b684f1c4b3e748f95c5a9a494ca36ec the checks were removed; this can lead to NULL pointer dereferences. This effectively reverts that portion of the commit. Signed-off-by: Ganesh Ajjanagadde--- libavcodec/psymodel.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c index 6274a49..edc5ac8 100644 --- a/libavcodec/psymodel.c +++ b/libavcodec/psymodel.c @@ -120,7 +120,11 @@ av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *av FF_FILTER_MODE_LOWPASS, FILT_ORDER, cutoff_coeff, 0.0, 0.0); if (ctx->fcoeffs) { -ctx->fstate = av_mallocz(sizeof(ctx->fstate[0]) * avctx->channels); +ctx->fstate = av_mallocz_array(sizeof(ctx->fstate[0]), avctx->channels); +if (!ctx->fstate) { +av_free(ctx); +return NULL; +} for (i = 0; i < avctx->channels; i++) ctx->fstate[i] = ff_iir_filter_init_state(FILT_ORDER); } -- 2.7.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel