sdl2-compat: SDL2Compat_ApplyQuirks: Avoid overflow for extremely long exe_name

From ca976ff7476505c4e0f95626b702d720b7eba692 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Mon, 15 Jun 2026 12:36:39 +0100
Subject: [PATCH] SDL2Compat_ApplyQuirks: Avoid overflow for extremely long
 exe_name

The length of `exe_name` is (at least in theory) unbounded, so adding
anything to it could overflow, but we know that the right-hand side
of the `<=` evaluates to a positive constant.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 src/sdl2_compat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index b6d1cada..e80837af 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -898,7 +898,7 @@ SDL2Compat_ApplyQuirks(bool force_x11)
     if (WantDebugLogging) {
         const char *lead = "sdl2-compat: This app appears to be named:";
         char msg[256];
-        if ((SDL2Compat_strlen(lead) + SDL2Compat_strlen(exe_name) + 2) <= sizeof (msg)) {
+        if (SDL2Compat_strlen(exe_name) <= sizeof (msg) - (SDL2Compat_strlen(lead) + 2)) {
             char *p = msg;
             p = SDL2COMPAT_stpcpy(p, lead);
             p = SDL2COMPAT_stpcpy(p, " ");