Skip to content

[rcore] fix crash in InitWindow, due to unchecked result of InitPlatform #4803

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

Conversation

sleeptightAnsiC
Copy link
Contributor

Check the result of InitPlatform(), if it isn't 0, report the Error and return. This prevent crashes and allows for gracefully aborting or recovering by checking IsWindowReady().

I decided to use LOG_ERROR here, because this is a fatal error in most cases, and it will cause a crash when ignored. However, I'm not so sure about SYSTEM prefix. There was no good choice for it. It must be very generic because InitPlatform() can fail in multiple cases.

Tested on native x86_64 Linux, and on x86_64 MacOS 13.6.9 running in VM. With GLFW in both cases.

Partially-fixes: #4801

Check the result of InitPlatform(), if it isn't 0, report the Error
and return. This prevent crashes and allows for gracefully aborting
or recovering by checking IsWindowReady().

Partially-fixes: raysan5#4801
sleeptightAnsiC added a commit to sleeptightAnsiC/raylib that referenced this pull request Mar 1, 2025
Small style change that doesn't impact how the code behaves here.
Variable 'result' is not used anywhere else in this block,
it's just for compliance with Raylib's coding conventions.

Requested in PR: raysan5#4803 (comment)
Small style change that doesn't impact how the code behaves here.
Variable 'result' is not used anywhere else in this block,
it's just for compliance with Raylib's coding conventions.

Requested in PR: raysan5#4803 (comment)
@sleeptightAnsiC sleeptightAnsiC force-pushed the fix_rcore__InitWindow_crash_when_InitPlatform_fails branch from fc0af3c to ead2952 Compare March 2, 2025 15:46
...as this is preferred over LOG_ERROR.

Requested-by: raysan5#4803 (comment)
@sleeptightAnsiC
Copy link
Contributor Author

sleeptightAnsiC commented Mar 2, 2025

Sorry for inconvenience @raysan5
I simply didn't notice all issues in invalid code style, the first time you pointed it out.
Everything should be resolved now. I would suggest squash+merge ?

@raysan5 raysan5 merged commit 3415939 into raysan5:master Mar 2, 2025
15 checks passed
@raysan5
Copy link
Owner

raysan5 commented Mar 2, 2025

@sleeptightAnsiC Thanks for the quick review! About the LOG_WARNING, I always try to give the user ownership over errors, as well as input provided info.

@orcmid
Copy link
Contributor

orcmid commented Mar 2, 2025

@sleeptightAnsiC Thanks for the quick review! About the LOG_WARNING, I always try to give the user ownership over errors, as well as input provided info.

Who is "the user" in this context?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants