Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: Fix SDL_GetBasePath() truncating paths #4437

Merged
merged 1 commit into from
Jun 13, 2021
Merged

Windows: Fix SDL_GetBasePath() truncating paths #4437

merged 1 commit into from
Jun 13, 2021

Conversation

pmttavara
Copy link
Contributor

@pmttavara pmttavara commented Jun 11, 2021

Tested on Windows 10 x64, versions 19041 and 10586.

Description

SDL_GetBasePath tries to reallocate its temporary buffer for long paths, but GetModuleFileNameExW always truncates and succeeds, so len was always equal to buflen - 1 which is 127.

Easily fixed by checking for buflen - 1 instead of buflen.

For paths longer than MAX_PATH, this problem sometimes got hidden by Windows path shortening (C:\PROGRA~1\ etc.).

Existing Issue(s)

No issue for this bug AFAICT.

EDIT: Fixes #4439.

Originally caused by the patch written for #1390.

SDL_GetBasePath grows its path buffer for long paths, but GetModuleFileNameExW always truncates and succeeds,
so `len` was always equal to (buflen - 1) which is 127. This is easily fixed by checking for (buflen - 1) instead of buflen.
For paths longer than MAX_PATH, this problem sometimes got hidden by Windows path shortening ("C:\PROGRA~1\" etc.).

Tested on Windows 10 x64 19041 and 10586.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants