PR #22509 opened by Niklas Haas (haasn)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22509
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22509.patch

Just use uintptr_t, it accomplishes the exact same thing while being defined
behavior.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <[email protected]>


>From ab2172c466e2bc80ea43a5b9130114f53c04b8a6 Mon Sep 17 00:00:00 2001
From: Niklas Haas <[email protected]>
Date: Sun, 15 Mar 2026 12:21:00 +0100
Subject: [PATCH] swscale/ops_backend: avoid UB (null pointer arithmetic)

Just use uintptr_t, it accomplishes the exact same thing while being defined
behavior.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/ops_backend.h     | 4 ++--
 libswscale/ops_tmpl_common.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libswscale/ops_backend.h b/libswscale/ops_backend.h
index b1616f6b02..e909295d4b 100644
--- a/libswscale/ops_backend.h
+++ b/libswscale/ops_backend.h
@@ -44,8 +44,8 @@
  * directly incremented by the corresponding read/write functions.
  */
 typedef struct SwsOpIter {
-    const uint8_t *in[4];
-    uint8_t *out[4];
+    uintptr_t in[4];
+    uintptr_t out[4];
     int x, y;
 } SwsOpIter;
 
diff --git a/libswscale/ops_tmpl_common.c b/libswscale/ops_tmpl_common.c
index 1f3eb6aa67..e95a164ccf 100644
--- a/libswscale/ops_tmpl_common.c
+++ b/libswscale/ops_tmpl_common.c
@@ -187,8 +187,8 @@ static void fn(process)(const SwsOpExec *exec, const void 
*priv,
     SwsOpIter iterdata;
     SwsOpIter *iter = &iterdata; /* for CONTINUE() macro to work */
     for (int i = 0; i < 4; i++) {
-        iter->in[i]  = exec->in[i];
-        iter->out[i] = exec->out[i];
+        iter->in[i]  = (uintptr_t) exec->in[i];
+        iter->out[i] = (uintptr_t) exec->out[i];
     }
 
     for (iter->y = y_start; iter->y < y_end; iter->y++) {
-- 
2.52.0

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

Reply via email to