From 8248ce624a0f1ee2b9295b29b4c849e7092b9b3e Mon Sep 17 00:00:00 2001 From: "nova@twinkpad (fedora)" Date: Mon, 11 Aug 2025 09:52:11 +1000 Subject: [PATCH] the FUCK? --- wm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/wm.c b/wm.c index 2db6ab2..afb681a 100644 --- a/wm.c +++ b/wm.c @@ -1,3 +1,4 @@ +// I love gays! #include "mouse.h" #include "gpu.h" #include @@ -21,7 +22,16 @@ size_t window_count = 0; void add_window(Window new_window) { - windows = realloc(windows, sizeof(Window) * (window_count + 1)); + Window *temp = realloc(windows, sizeof(Window) * (window_count + 1)); + if (temp == NULL) + { + fprintf(stderr, "Failed to allocate memory for new window.\n"); + // The original 'windows' pointer is still valid, so we should free it + // and its contents before exiting to avoid memory leaks. + destroy_windows(windows, window_count); + exit(EXIT_FAILURE); + } + windows = temp; windows[window_count++] = new_window; } int ***alloc_rgb_buffer(int height, int width)