From 5f8e0ebf584b069b15f88240bda40a8263790079 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 26 Jan 2025 19:29:47 -0800 Subject: [PATCH] Fixed memory leak at shutdown --- src/events/SDL_pen.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/events/SDL_pen.c b/src/events/SDL_pen.c index afc2ea031d..71ddd4c0d8 100644 --- a/src/events/SDL_pen.c +++ b/src/events/SDL_pen.c @@ -109,9 +109,14 @@ bool SDL_InitPen(void) void SDL_QuitPen(void) { SDL_DestroyRWLock(pen_device_rwlock); - pen_device_rwlock = 0; - SDL_free(pen_devices); - pen_devices = NULL; + pen_device_rwlock = NULL; + if (pen_devices) { + for (int i = pen_device_count; i--; ) { + SDL_free(pen_devices[i].name); + } + SDL_free(pen_devices); + pen_devices = NULL; + } pen_device_count = 0; pen_touching = 0; }