diff options
author | Tim Wiederhake <twied@gmx.net> | 2024-03-16 13:07:19 +0100 |
---|---|---|
committer | Tim Wiederhake <twied@gmx.net> | 2024-03-16 13:07:19 +0100 |
commit | a62500505d57a4dc2c77bbbd7d0bfb832a5aa857 (patch) | |
tree | 71647ddc177d971781d67017244bf511ab90353b /src/twm.c | |
parent | e60c2914c354d4725d170e4fe4f14456caccd3cc (diff) |
Fix memory leak in FindFontSet
Valgrind results before:
definitely lost: 800 bytes in 23 blocks
indirectly lost: 872 bytes in 6 blocks
possibly lost: 0 bytes in 0 blocks
still reachable: 991,316 bytes in 1,795 blocks
suppressed: 0 bytes in 0 blocks
Valgrind results after:
definitely lost: 200 bytes in 17 blocks
indirectly lost: 0 bytes in 0 blocks
possibly lost: 0 bytes in 0 blocks
still reachable: 918,812 bytes in 994 blocks
suppressed: 0 bytes in 0 blocks
Signed-off-by: Tim Wiederhake <twied@gmx.net>
Part-of: <https://gitlab.freedesktop.org/xorg/app/twm/-/merge_requests/29>
Diffstat (limited to 'src/twm.c')
-rw-r--r-- | src/twm.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -813,6 +813,25 @@ CreateFonts(void) Scr->HaveFonts = TRUE; } +static void +DestroyFonts(void) +{ + for (int i = 0; i < NumScreens; ++i) { + ScreenInfo *scr = ScreenList[i]; + + if (!scr) { + continue; + } + + DestroyFont(&scr->TitleBarFont); + DestroyFont(&scr->MenuFont); + DestroyFont(&scr->IconFont); + DestroyFont(&scr->SizeFont); + DestroyFont(&scr->IconManagerFont); + DestroyFont(&scr->DefaultFont); + } +} + void RestoreWithdrawnLocation(TwmWindow *tmp) { @@ -903,6 +922,7 @@ Done(XtPointer client_data _X_UNUSED, XtSignalId *si2 _X_UNUSED) { if (dpy) { Reborder(CurrentTime); + DestroyFonts(); XCloseDisplay(dpy); } |