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>
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);
{
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);
}