NULL deref in SDL_ShouldIgnoreGamepad when GameInput's displayName is NULL (Xbox console)
Hey,
I'm hitting a NULL deref in the GameInput joystick backend on Xbox console the moment a controller is recognized.
`GameInputDeviceInfo::displayName` comes through as NULL on my setup, so in `SDL_gameinputjoystick.cpp:GAMEINPUT_InternalAddOrFind` the local `product_string` stays NULL and gets passed straight into `SDL_ShouldIgnoreJoystick` → `SDL_ShouldIgnoreGamepad`. From there `SDL_startswith(name, ...)` calls `SDL_strncmp(NULL, ...)` and we crash in `ucrtbase!strncmp` with `EXCEPTION_ACCESS_VIOLATION` reading 0x0.
I've reproduced it on two separate machines with the default Xbox controller, so it doesn't seem to be a one-off on my end. Is `displayName == NULL` a state SDL should be guarding against, or is the expectation that GameInput always populates it and something else is wrong here?
One detail in case it matters: we end up compiling against `GAMEINPUT_API_VERSION = 0` because that's what `src/core/windows/SDL_gameinput.h` defaults to, and nothing in `VisualC-GDK` overrides it. So we're on the `info->displayName->data` branch. But I don't think that changes the root cause, since the NULL check on `info->displayName` short-circuits before any deref either way.
Cheers!
关闭于 2026-04-25 1 条评论