]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: make reload code more robust
authorKarel Zak <kzak@redhat.com>
Thu, 2 May 2024 08:54:04 +0000 (10:54 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 6 May 2024 07:22:36 +0000 (09:22 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit b5e2de00cc6b79a2522342ff99cce6bb87743094)

term-utils/agetty.c

index c2e1a0cf4075ad90ca876ee3e81f579d424b018f..55d9a6134daa7d412b0230dd5b7b5b807f77148e 100644 (file)
@@ -1877,6 +1877,7 @@ static int issue_is_changed(struct issue *ie)
                free(ie->mem_old);
                ie->mem_old = ie->mem;
                ie->mem = NULL;
+               ie->mem_sz = 0;
                return 0;
        }
 
@@ -1903,7 +1904,7 @@ static void print_issue_file(struct issue *ie,
                }
        }
 
-       if (ie->mem_sz)
+       if (ie->mem_sz && ie->mem)
                write_all(STDOUT_FILENO, ie->mem, ie->mem_sz);
 
        if (ie->do_tcrestore) {