From 46eeba86a2251e6882342c2cb216b51d59fc9d25 Mon Sep 17 00:00:00 2001 From: "nova@twinkpad (fedora)" Date: Mon, 11 Aug 2025 09:41:39 +1000 Subject: [PATCH 1/2] Remove test comments, put some in a C file, maybe it will see then --- wm.c | 1 + wm.h | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/wm.c b/wm.c index 2db6ab2..353ed2d 100644 --- a/wm.c +++ b/wm.c @@ -1,3 +1,4 @@ +// I love gays! #include "mouse.h" #include "gpu.h" #include diff --git a/wm.h b/wm.h index 3d0dfa2..731d011 100644 --- a/wm.h +++ b/wm.h @@ -20,8 +20,4 @@ extern size_t window_count; void wm_init(int bufptr[800][1280][3]); void wm_draw(volatile int *running); -#endif // WM_H - -// dabatases (test commit for codacy to give status checks) -// motherfucker its supposed to be PR not push -// fucker \ No newline at end of file +#endif // WM_H \ No newline at end of file From c128a319dbac36ce50faeb8bf0e0c4e207faff61 Mon Sep 17 00:00:00 2001 From: "nova@twinkpad (fedora)" Date: Mon, 11 Aug 2025 09:51:23 +1000 Subject: [PATCH 2/2] Fix Non free on fail of Realloc in wm.c/add_window function --- wm.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wm.c b/wm.c index 353ed2d..afb681a 100644 --- a/wm.c +++ b/wm.c @@ -22,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)