[FFmpeg-cvslog] lavfi/vf_zscale: fix tmp buffer ptr alignment for zimg_filter_graph_process

Pavel Koshevoy git at videolan.org
Sun Nov 17 17:37:40 EET 2024


ffmpeg | branch: release/7.1 | Pavel Koshevoy <pkoshevoy at gmail.com> | Sat Nov  9 10:05:16 2024 -0700| [85f389520dbda5054d1379e7270f302ff1eb3b5e] | committer: James Almer

lavfi/vf_zscale: fix tmp buffer ptr alignment for zimg_filter_graph_process

Signed-off-by: James Almer <jamrial at gmail.com>
(cherry picked from commit 7b302f4db7d335f4dd42cffb461b2b0db6c00749)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=85f389520dbda5054d1379e7270f302ff1eb3b5e
---

 libavfilter/vf_zscale.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index b0316f5bb8..d561466c56 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -626,9 +626,12 @@ static int graphs_build(AVFrame *in, AVFrame *out, const AVPixFmtDescriptor *des
     if (ret)
         return print_zimg_error(ctx);
 
+    if (size > (SIZE_MAX - ZIMG_ALIGNMENT))
+        return AVERROR(ENOMEM);
+
     if (s->tmp[job_nr])
         av_freep(&s->tmp[job_nr]);
-    s->tmp[job_nr] = av_calloc(size, 1);
+    s->tmp[job_nr] = av_mallocz(size + ZIMG_ALIGNMENT);
     if (!s->tmp[job_nr])
         return AVERROR(ENOMEM);
 
@@ -748,7 +751,9 @@ static int filter_slice(AVFilterContext *ctx, void *data, int job_nr, int n_jobs
     }
     if (!s->graph[job_nr])
         return AVERROR(EINVAL);
-    ret = zimg_filter_graph_process(s->graph[job_nr], &src_buf, &dst_buf, s->tmp[job_nr], 0, 0, 0, 0);
+    ret = zimg_filter_graph_process(s->graph[job_nr], &src_buf, &dst_buf,
+                                    (uint8_t *)FFALIGN((uintptr_t)s->tmp[job_nr], ZIMG_ALIGNMENT),
+                                    0, 0, 0, 0);
     if (ret)
         return print_zimg_error(ctx);
 
@@ -763,7 +768,9 @@ static int filter_slice(AVFilterContext *ctx, void *data, int job_nr, int n_jobs
 
         if (!s->alpha_graph[job_nr])
             return AVERROR(EINVAL);
-        ret = zimg_filter_graph_process(s->alpha_graph[job_nr], &src_buf, &dst_buf, s->tmp[job_nr], 0, 0, 0, 0);
+        ret = zimg_filter_graph_process(s->alpha_graph[job_nr], &src_buf, &dst_buf,
+                                        (uint8_t *)FFALIGN((uintptr_t)s->tmp[job_nr], ZIMG_ALIGNMENT),
+                                        0, 0, 0, 0);
         if (ret)
             return print_zimg_error(ctx);
     }



More information about the ffmpeg-cvslog mailing list