Message ID | 20200615014050.14473-1-andreas.rheinhardt@gmail.com |
---|---|
State | Accepted |
Commit | 3aa0be003e98006215f670e712851a443d3f3c5f |
Headers | show |
Series | [FFmpeg-devel] avcodec/iirfilter: Fix memleak | expand |
Context | Check | Description |
---|---|---|
andriy/default | pending | |
andriy/make | success | Make finished |
andriy/make_fate | success | Make fate finished |
On Mon, Jun 15, 2020 at 03:40:50AM +0200, Andreas Rheinhardt wrote: > Commit 17e88bf0df21906633a7d36d9f2aeeeb5b6d3267 created a memleak by > removing a call to ff_iir_filter_free_coeffsp on error; this has been > found by Coverity (ID 1464159). This commit fixes the memleak by > readding the call to ff_iir_filter_free_coeffsp. > > Notice that this is not a simple revert, because several macros that > were used before 17e88bf0df21906633a7d36d9f2aeeeb5b6d3267 were replaced > in commit 44863b2c2d5a31d82aafa71cdbd180d6bfbed5b4 and completely removed > in 2658680df4fc606522e5f65899afb9a98b47d287. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> > --- > The commits mentioned above are not in 4.3. > > libavcodec/iirfilter.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/iirfilter.c b/libavcodec/iirfilter.c > index 9f76bce8b8..cd5bbc943a 100644 > --- a/libavcodec/iirfilter.c > +++ b/libavcodec/iirfilter.c > @@ -174,7 +174,7 @@ av_cold struct FFIIRFilterCoeffs *ff_iir_filter_init_coeffs(void *avc, > if (!(c = av_mallocz(sizeof(*c))) || > !(c->cx = av_malloc (sizeof(c->cx[0]) * ((order >> 1) + 1))) || > !(c->cy = av_malloc (sizeof(c->cy[0]) * order))) > - return NULL; > + goto free; > c->order = order; > > switch (filt_type) { > @@ -188,11 +188,13 @@ av_cold struct FFIIRFilterCoeffs *ff_iir_filter_init_coeffs(void *avc, > break; > default: > av_log(avc, AV_LOG_ERROR, "filter type is not currently implemented\n"); > - return NULL; > + goto free; > } > > if (!ret) > return c; > +free: > + ff_iir_filter_free_coeffsp(&c); > return NULL; > } Look good to me, I notice it and haven't submit patch yet. > > -- > 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/iirfilter.c b/libavcodec/iirfilter.c index 9f76bce8b8..cd5bbc943a 100644 --- a/libavcodec/iirfilter.c +++ b/libavcodec/iirfilter.c @@ -174,7 +174,7 @@ av_cold struct FFIIRFilterCoeffs *ff_iir_filter_init_coeffs(void *avc, if (!(c = av_mallocz(sizeof(*c))) || !(c->cx = av_malloc (sizeof(c->cx[0]) * ((order >> 1) + 1))) || !(c->cy = av_malloc (sizeof(c->cy[0]) * order))) - return NULL; + goto free; c->order = order; switch (filt_type) { @@ -188,11 +188,13 @@ av_cold struct FFIIRFilterCoeffs *ff_iir_filter_init_coeffs(void *avc, break; default: av_log(avc, AV_LOG_ERROR, "filter type is not currently implemented\n"); - return NULL; + goto free; } if (!ret) return c; +free: + ff_iir_filter_free_coeffsp(&c); return NULL; }
Commit 17e88bf0df21906633a7d36d9f2aeeeb5b6d3267 created a memleak by removing a call to ff_iir_filter_free_coeffsp on error; this has been found by Coverity (ID 1464159). This commit fixes the memleak by readding the call to ff_iir_filter_free_coeffsp. Notice that this is not a simple revert, because several macros that were used before 17e88bf0df21906633a7d36d9f2aeeeb5b6d3267 were replaced in commit 44863b2c2d5a31d82aafa71cdbd180d6bfbed5b4 and completely removed in 2658680df4fc606522e5f65899afb9a98b47d287. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- The commits mentioned above are not in 4.3. libavcodec/iirfilter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)