From 83b9f8f9daccc4dfd477281c505529f00dc211c2 Mon Sep 17 00:00:00 2001 From: Daemo Date: Sun, 9 Aug 2026 02:22:57 +0200 Subject: [PATCH] Fixed crash on NULL window titles + typo --- runtime/Includes/Core/Application.h | 2 +- runtime/Includes/Core/Application.inl | 9 +++++++-- runtime/Sources/Core/Bridge.cpp | 7 ++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/runtime/Includes/Core/Application.h b/runtime/Includes/Core/Application.h index a9a1c77..e8bcb72 100644 --- a/runtime/Includes/Core/Application.h +++ b/runtime/Includes/Core/Application.h @@ -23,7 +23,7 @@ namespace mlx inline void OnEvent(mlx_window win, int event, void(*f)(int, void*), void* param) noexcept; - inline mlx_window NewGraphicsSuport(const mlx_window_create_info* info); + inline mlx_window NewGraphicsSupport(const mlx_window_create_info* info); inline NonOwningPtr GetGraphicsSupport(mlx_window win); inline void DestroyGraphicsSupport(mlx_window win); diff --git a/runtime/Includes/Core/Application.inl b/runtime/Includes/Core/Application.inl index c0d00b8..edb70d7 100644 --- a/runtime/Includes/Core/Application.inl +++ b/runtime/Includes/Core/Application.inl @@ -60,7 +60,7 @@ namespace mlx m_fps.SetMaxFPS(fps); } - mlx_window Application::NewGraphicsSuport(const mlx_window_create_info* info) + mlx_window Application::NewGraphicsSupport(const mlx_window_create_info* info) { MLX_PROFILE_FUNCTION(); if(!info) @@ -68,6 +68,11 @@ namespace mlx Error("invalid window create info (NULL)"); return nullptr; } + if (info->title == nullptr) + { + mlx::Error("invalid window title (NULL)"); + return nullptr; + } mlx_window window; try { window = new mlx_window_handler; } @@ -134,7 +139,7 @@ namespace mlx { m_hooks.emplace_back(f, param); } - + void Application::LoopEnd() noexcept { m_in.Finish(); diff --git a/runtime/Sources/Core/Bridge.cpp b/runtime/Sources/Core/Bridge.cpp index 4123d6a..dc90707 100644 --- a/runtime/Sources/Core/Bridge.cpp +++ b/runtime/Sources/Core/Bridge.cpp @@ -61,7 +61,7 @@ extern "C" mlx_window mlx_new_window(mlx_context mlx, const mlx_window_create_info* info) { MLX_CHECK_APPLICATION_POINTER(mlx); - return mlx->app->NewGraphicsSuport(info); + return mlx->app->NewGraphicsSupport(info); } void mlx_destroy_window(mlx_context mlx, mlx_window win) @@ -90,6 +90,11 @@ extern "C" void mlx_set_window_title(mlx_context mlx, mlx_window win, const char* title) { + if (title == nullptr) + { + mlx::Error("invalid window title (NULL)"); + return; + } MLX_CHECK_APPLICATION_POINTER(mlx); mlx::NonOwningPtr gs = mlx->app->GetGraphicsSupport(win); if(!gs && !gs->HasWindow())