Skip to content

Conversation

@bleeqer
Copy link
Contributor

@bleeqer bleeqer commented Oct 26, 2025

Problem:
When SDL_OpenFileStorage(NULL) is called with a NULL base path (which is explicitly allowed by the API),
calling SDL_GlobStorageDirectory on that storage causes a segmentation fault.
The crash occurs in GENERIC_EnumerateStorageDirectory at line 82 where SDL_strlen is called on the NULL userdata pointer without checking if it's NULL first.

Solution:
Add a NULL check before calling SDL_strlen on the userdata pointer.
If userdata is NULL, set base_len to 0, otherwise calculate the length normally.
This matches the pattern used by GENERIC_INTERNAL_CreateFullPath which already handles NULL base paths correctly.

Happy to hear any feedback you might have.
Hope you're having a great day!

Fixes #14060

@slouken slouken added this to the 3.4.0 milestone Oct 26, 2025
Copy link
Collaborator

@slouken slouken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. @icculus, is this related to any of the other storage issues in this milestone?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NULL base path in SDL_GlobStorageDirectory via SDL_OpenFileStorage(NULL) leads to NULL deref in GENERIC_EnumerateStorageDirectory

3 participants