From c72972fea261217a3f5a9dd5ab37d7360696b761 Mon Sep 17 00:00:00 2001 From: FintasticMan Date: Sat, 28 Dec 2024 13:52:38 +0000 Subject: [PATCH] [Examples/Intro] Fix NULL pointer deref due to huuge malloc It would probably be good to check that malloc doesn't fail, but for a simple example like this it should be fine. --- examples/introducing-clay-video-demo/main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/examples/introducing-clay-video-demo/main.c b/examples/introducing-clay-video-demo/main.c index e36f53a..88a0c15 100644 --- a/examples/introducing-clay-video-demo/main.c +++ b/examples/introducing-clay-video-demo/main.c @@ -79,10 +79,7 @@ int main(void) { Clay_Raylib_Initialize(1024, 768, "Introducing Clay Demo", FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_HIGHDPI | FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT); // Extra parameters to this function are new since the video was published uint64_t clayRequiredMemory = Clay_MinMemorySize(); - Clay_Arena clayMemory = (Clay_Arena) { - .memory = malloc((size_t)1024 * 1024 * 1024 * 1024), - .capacity = clayRequiredMemory - }; + Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(clayRequiredMemory, malloc(clayRequiredMemory)); Clay_Initialize(clayMemory, (Clay_Dimensions) { .width = GetScreenWidth(), .height = GetScreenHeight() @@ -302,4 +299,4 @@ int main(void) { Clay_Raylib_Render(renderCommands); EndDrawing(); } -} \ No newline at end of file +}