]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/colors: free unnecessary ncurses resources
authorKarel Zak <kzak@redhat.com>
Mon, 24 Jun 2024 08:00:33 +0000 (10:00 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 24 Jun 2024 08:00:33 +0000 (10:00 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/colors.c

index 0928770a3bbe94d24c8f854c66cd10431601ea54..a6800fd9e378802cf80ad6f185166c586207566b 100644 (file)
@@ -560,8 +560,11 @@ static int colors_terminal_is_ready(void)
        {
                int ret;
 
-               if (setupterm(NULL, STDOUT_FILENO, &ret) == 0 && ret == 1)
+               /* setupterm() allocates memory, del_curterm() deallocates it */
+               if (setupterm(NULL, STDOUT_FILENO, &ret) == 0 && ret == 1) {
                        ncolors = tigetnum("colors");
+                       del_curterm(cur_term);
+               }
        }
 #endif
        if (1 < ncolors) {