Skip to content

Commit 3415939

Browse files
[rcore] fix crash in InitWindow, due to unchecked result of InitPlatform (#4803)
* [rcore] fix crash in InitWindow, due to unchecked result of InitPlatform 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: #4801 * [rcore] style: store the result of InitPlatform() before checking it 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: #4803 (comment) * [rcore] use LOG_WARNING when InitPlatform() fails ...as this is preferred over LOG_ERROR. Requested-by: #4803 (comment)
1 parent b99c284 commit 3415939

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/rcore.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,13 @@ void InitWindow(int width, int height, const char *title)
681681

682682
// Initialize platform
683683
//--------------------------------------------------------------
684-
InitPlatform();
684+
int result = InitPlatform();
685+
686+
if (result != 0)
687+
{
688+
TRACELOG(LOG_WARNING, "SYSTEM: Failed to initialize Platform");
689+
return;
690+
}
685691
//--------------------------------------------------------------
686692

687693
// Initialize rlgl default data (buffers and shaders)

0 commit comments

Comments
 (0)