summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorMika Kuoppala <miku@iki.fi>2023-03-17 14:45:52 +0200
committerLeo Izen <leo.izen@gmail.com>2023-04-10 10:48:16 -0400
commit95d7b05e71a1da9fc38e04994adbb90ae6d356e4 (patch)
tree88f17a54df87369c807032278a9519ccb609fd20 /video
parent1808f264b3871891ff48875f0900be52ad4a3e1d (diff)
downloadmpv-95d7b05e71a1da9fc38e04994adbb90ae6d356e4.tar.bz2
mpv-95d7b05e71a1da9fc38e04994adbb90ae6d356e4.tar.xz
video/out/gpu: Fix compilation warning of out of bound access
Make the index into the arrays in copy_image() unsigned to make compiler trust that we dont access out of bounds.
Diffstat (limited to 'video')
-rw-r--r--video/out/gpu/video.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c
index 21e004cd43..cfd864680b 100644
--- a/video/out/gpu/video.c
+++ b/video/out/gpu/video.c
@@ -1338,18 +1338,20 @@ static const char *get_tex_swizzle(struct image *img)
// Copy a texture to the vec4 color, while increasing offset. Also applies
// the texture multiplier to the sampled color
-static void copy_image(struct gl_video *p, int *offset, struct image img)
+static void copy_image(struct gl_video *p, unsigned int *offset, struct image img)
{
- int count = img.components;
- assert(*offset + count <= 4);
- assert(img.padding + count <= 4);
-
- int id = pass_bind(p, img);
+ const unsigned int count = img.components;
char src[5] = {0};
char dst[5] = {0};
+
+ assert(*offset + count < sizeof(dst));
+ assert(img.padding + count < sizeof(src));
+
+ int id = pass_bind(p, img);
+
const char *tex_fmt = get_tex_swizzle(&img);
const char *dst_fmt = "rgba";
- for (int i = 0; i < count; i++) {
+ for (unsigned int i = 0; i < count; i++) {
src[i] = tex_fmt[img.padding + i];
dst[i] = dst_fmt[*offset + i];
}