SDL: Fixed potential double-free

From b99e19c0a2cbdd30b50e4272ad324c45e2741a28 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 5 Feb 2025 00:04:45 -0800
Subject: [PATCH] Fixed potential double-free

---
 src/video/x11/SDL_x11pen.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/video/x11/SDL_x11pen.c b/src/video/x11/SDL_x11pen.c
index c7e4c8bba6f05..f63654542f1c0 100644
--- a/src/video/x11/SDL_x11pen.c
+++ b/src/video/x11/SDL_x11pen.c
@@ -81,10 +81,12 @@ static bool X11_XInput2PenIsEraser(SDL_VideoDevice *_this, int deviceid, char *d
             }
 
             if (tooltype_name) {
-                if (0 == SDL_strcasecmp(tooltype_name, PEN_ERASER_NAME_TAG)) {
+                if (SDL_strcasecmp(tooltype_name, PEN_ERASER_NAME_TAG) == 0) {
                     result = true;
                 }
-                X11_XFree(tooltype_name_info);
+                if (tooltype_name != (char *)tooltype_name_info) {
+                    X11_XFree(tooltype_name_info);
+                }
                 X11_XFree(tooltype_name);
 
                 return result;