changeset 2702:0a6d644c47aa

Avoid crash if using an older SDL2 DLL than the one we compiled with
author Michael Pavone <pavone@retrodev.com>
date Fri, 04 Jul 2025 21:23:48 -0700
parents 5ca4e0fd761b
children 829205a9647a
files render_sdl.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/render_sdl.c	Fri Jul 04 19:35:50 2025 -0700
+++ b/render_sdl.c	Fri Jul 04 21:23:48 2025 -0700
@@ -2636,7 +2636,10 @@
 	if (!button_lookup) {
 		for (int i = SDL_CONTROLLER_BUTTON_A; i < SDL_CONTROLLER_BUTTON_MAX; i++)
 		{
-			button_lookup = tern_insert_int(button_lookup, SDL_GameControllerGetStringForButton(i), i);
+			const char *bname = SDL_GameControllerGetStringForButton(i);
+			if (bname) {
+				button_lookup = tern_insert_int(button_lookup, bname, i);
+			}
 		}
 		//alternative Playstation-style names
 		button_lookup = tern_insert_int(button_lookup, "cross", SDL_CONTROLLER_BUTTON_A);