Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-12-01 12:56:26 +0300
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-05-20 01:24:23 +0300
commit2980fb5704654af3decd99c3c16b9622fc6c3463 (patch)
tree394f5e15606dd57a53275efaf199422c22b9cf70 /libavfilter
parenteae4b6142223d6f214b97c00bc498884f3b98065 (diff)
avfilter/vf_unsharp: Don't dereference NULL
The unsharp filter uses an array of arrays of uint32_t, each of which is separately allocated. These arrays also need to freed separately; but before doing so, one needs to check whether the array of arrays has actually been allocated, otherwise one would dereference a NULL pointer. This fixes #8408. Furthermore, the array of arrays needs to be zero-initialized so that no uninitialized pointer will be freed in case an allocation of one of the individual arrays fails. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 710ab136931ff228b355d87512b0d4ca4e94656a)
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_unsharp.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c
index af05833a5d..7481ac05e8 100644
--- a/libavfilter/vf_unsharp.c
+++ b/libavfilter/vf_unsharp.c
@@ -218,7 +218,7 @@ static int init_filter_param(AVFilterContext *ctx, UnsharpFilterParam *fp, const
effect, effect_type, fp->msize_x, fp->msize_y, fp->amount / 65535.0);
fp->sr = av_malloc_array((MAX_MATRIX_SIZE - 1) * s->nb_threads, sizeof(uint32_t));
- fp->sc = av_malloc_array(2 * fp->steps_y * s->nb_threads, sizeof(uint32_t **));
+ fp->sc = av_mallocz_array(2 * fp->steps_y * s->nb_threads, sizeof(uint32_t *));
if (!fp->sr || !fp->sc)
return AVERROR(ENOMEM);
@@ -258,9 +258,11 @@ static void free_filter_param(UnsharpFilterParam *fp, int nb_threads)
{
int z;
- for (z = 0; z < 2 * fp->steps_y * nb_threads; z++)
- av_freep(&fp->sc[z]);
- av_freep(&fp->sc);
+ if (fp->sc) {
+ for (z = 0; z < 2 * fp->steps_y * nb_threads; z++)
+ av_freep(&fp->sc[z]);
+ av_freep(&fp->sc);
+ }
av_freep(&fp->sr);
}