From 03933f35641c65f502dc1e05ad8308e71a44d4fb Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 18 Mar 2017 20:22:50 +0100 Subject: vo_opengl: fix some undefined behavior The gl_timer_last_us() function could access samples[-1]. Fix by coercing to unsigned, so the % will put it into index [0,max). The real value returned in this corner case doesn't mean too much, I guess. --- video/out/opengl/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index 4fbe4053dc..9b01912041 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -1061,7 +1061,7 @@ void gl_sc_generate(struct gl_shader_cache *sc) // How many samples to keep around, for the sake of average and peak // calculations. This corresponds to a few seconds (exact time variable) -#define QUERY_SAMPLE_SIZE 256 +#define QUERY_SAMPLE_SIZE 256u struct gl_timer { GL *gl; -- cgit v1.2.3