This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new 9a01c1cb6a avfilter/vf_removelogo: free the whole mask on allocation 
failure
9a01c1cb6a is described below

commit 9a01c1cb6a4cf87529fe9898b66ec55c5b032639
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Mon Jun 29 01:35:05 2026 +0200
Commit:     michaelni <[email protected]>
CommitDate: Tue Jun 30 11:15:33 2026 +0000

    avfilter/vf_removelogo: free the whole mask on allocation failure
    
    Found-by: Ao Xijie
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavfilter/vf_removelogo.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/libavfilter/vf_removelogo.c b/libavfilter/vf_removelogo.c
index 1da5f5d0c7..7285f5336a 100644
--- a/libavfilter/vf_removelogo.c
+++ b/libavfilter/vf_removelogo.c
@@ -311,22 +311,18 @@ static av_cold int init(AVFilterContext *ctx)
        the filter is applied, the mask size is determined on a pixel
        by pixel basis, with pixels nearer the edge of the logo getting
        smaller mask sizes. */
-    mask = (int ***)av_malloc_array(s->max_mask_size + 1, sizeof(int **));
+    mask = av_calloc(s->max_mask_size + 1, sizeof(*mask));
     if (!mask)
         return AVERROR(ENOMEM);
 
     for (a = 0; a <= s->max_mask_size; a++) {
-        mask[a] = (int **)av_malloc_array((a * 2) + 1, sizeof(int *));
-        if (!mask[a]) {
-            av_free(mask);
-            return AVERROR(ENOMEM);
-        }
+        mask[a] = av_calloc((a * 2) + 1, sizeof(*mask[a]));
+        if (!mask[a])
+            goto mask_fail;
         for (b = -a; b <= a; b++) {
-            mask[a][b + a] = (int *)av_malloc_array((a * 2) + 1, sizeof(int));
-            if (!mask[a][b + a]) {
-                av_free(mask);
-                return AVERROR(ENOMEM);
-            }
+            mask[a][b + a] = av_malloc_array((a * 2) + 1, sizeof(*mask[a][b + 
a]));
+            if (!mask[a][b + a])
+                goto mask_fail;
             for (c = -a; c <= a; c++) {
                 if ((b * b) + (c * c) <= (a * a)) /* Circular 0/1 mask. */
                     mask[a][b + a][c + a] = 1;
@@ -351,6 +347,16 @@ static av_cold int init(AVFilterContext *ctx)
     SHOW_LOGO_INFO(half);
 
     return 0;
+
+mask_fail:
+    for (a = 0; a <= s->max_mask_size; a++) {
+        if (mask[a])
+            for (b = 0; b < (a * 2) + 1; b++)
+                av_free(mask[a][b]);
+        av_free(mask[a]);
+    }
+    av_free(mask);
+    return AVERROR(ENOMEM);
 }
 
 static int config_props_input(AVFilterLink *inlink)

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to