From b32cf754e58d323b4690105c2dbb79ce2e14b8b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Wed, 12 Mar 2025 22:53:44 +0100 Subject: [PATCH] opengl/utils: use uintptr_t for arithmetics with possible zero value Fixes UBSAN warnings, applying non-zero offset to null pointer. --- video/out/opengl/utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index cbf00fd2f6..18837a8e8c 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -80,7 +80,7 @@ void gl_upload_tex(GL *gl, GLenum target, GLenum format, GLenum type, int x, int y, int w, int h) { int bpp = gl_bytes_per_pixel(format, type); - const uint8_t *data = dataptr; + uintptr_t data = (uintptr_t)dataptr; int y_max = y + h; if (w <= 0 || h <= 0 || !bpp) return; @@ -95,11 +95,11 @@ void gl_upload_tex(GL *gl, GLenum target, GLenum format, GLenum type, slice = 1; // very inefficient, but at least it works } for (; y + slice <= y_max; y += slice) { - gl->TexSubImage2D(target, 0, x, y, w, slice, format, type, data); + gl->TexSubImage2D(target, 0, x, y, w, slice, format, type, (void *)data); data += stride * slice; } if (y < y_max) - gl->TexSubImage2D(target, 0, x, y, w, y_max - y, format, type, data); + gl->TexSubImage2D(target, 0, x, y, w, y_max - y, format, type, (void *)data); if (gl->mpgl_caps & MPGL_CAP_ROW_LENGTH) gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0); gl->PixelStorei(GL_UNPACK_ALIGNMENT, 4);