From f3d7df54e2c06ba1921621d069984c599b572372 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 24 Apr 2026 07:30:12 -0700 Subject: [PATCH] Fixed crash in SDL_startswith() when passed NULL strings Fixes https://github.com/libsdl-org/SDL/issues/15451 --- src/SDL_utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SDL_utils.c b/src/SDL_utils.c index 2667390ac6..a4a0d77614 100644 --- a/src/SDL_utils.c +++ b/src/SDL_utils.c @@ -111,7 +111,8 @@ void SDL_CalculateFraction(float x, int *numerator, int *denominator) bool SDL_startswith(const char *string, const char *prefix) { - if (SDL_strncmp(string, prefix, SDL_strlen(prefix)) == 0) { + if (string && prefix && + SDL_strncmp(string, prefix, SDL_strlen(prefix)) == 0) { return true; } return false;