ソースを参照

[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: https://github.com/raysan5/raylib/issues/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: https://github.com/raysan5/raylib/pull/4803#discussion_r1976502788

* [rcore] use LOG_WARNING when InitPlatform() fails

...as this is preferred over LOG_ERROR.

Requested-by: https://github.com/raysan5/raylib/pull/4803#discussion_r1976651724
pull/4811/head
sleeptightAnsiC 2ヶ月前
committed by GitHub
コミット
34159399cf
この署名に対応する既知のキーがデータベースに存在しません GPGキーID: B5690EEEBB952194
1個のファイルの変更7行の追加1行の削除
  1. +7
    -1
      src/rcore.c

+ 7
- 1
src/rcore.c ファイルの表示

@ -681,7 +681,13 @@ void InitWindow(int width, int height, const char *title)
// Initialize platform // Initialize platform
//-------------------------------------------------------------- //--------------------------------------------------------------
InitPlatform();
int result = InitPlatform();
if (result != 0)
{
TRACELOG(LOG_WARNING, "SYSTEM: Failed to initialize Platform");
return;
}
//-------------------------------------------------------------- //--------------------------------------------------------------
// Initialize rlgl default data (buffers and shaders) // Initialize rlgl default data (buffers and shaders)

読み込み中…
キャンセル
保存