-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[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
[rcore] fix crash in InitWindow, due to unchecked result of InitPlatform #4803
Conversation
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
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)
fc0af3c
to
ead2952
Compare
...as this is preferred over LOG_ERROR. Requested-by: raysan5#4803 (comment)
Sorry for inconvenience @raysan5 |
@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? |
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 aboutSYSTEM
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