Skip to content

Commit

Permalink
SDL: Fix invalid std::string{nullptr} when SDL_GetScancodeName return…
Browse files Browse the repository at this point in the history
…s nullptr
  • Loading branch information
maxmitti committed Sep 8, 2024
1 parent 767e0da commit b98d764
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/C4KeyboardInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,12 @@ std::string C4KeyCodeEx::KeyCode2String(C4KeyCode wCode, bool fHumanReadable, bo
#elif defined(USE_X11)
return XKeysymToString(wCode);
#elif defined(USE_SDL_MAINLOOP)
return SDL_GetScancodeName(static_cast<SDL_Scancode>(wCode));
const auto name = SDL_GetScancodeName(static_cast<SDL_Scancode>(wCode));
if (!name)
{
return "invalid";
}
return name;
#else
return "unknown";
#endif
Expand Down

0 comments on commit b98d764

Please sign in to comment.