From 40e147a933b0b0664ffd5b7081a6b367bbedd46e Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 25 Oct 2007 22:10:07 +0200 Subject: [PATCH] setterm: opened file leaving unclosed Co-Author: lizf Signed-off-by: Karel Zak --- misc-utils/setterm.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/misc-utils/setterm.c b/misc-utils/setterm.c index 5d889ea4..ebf7f0ac 100644 --- a/misc-utils/setterm.c +++ b/misc-utils/setterm.c @@ -1133,24 +1133,22 @@ screendump(int vcnum, FILE *F) { } if (fd < 0) { sprintf(infile, "/dev/vcsa%d", vcnum); - goto error; + goto read_error; } if (read(fd, header, 4) != 4) - goto error; + goto read_error; rows = header[0]; cols = header[1]; if (rows * cols == 0) - goto error; + goto read_error; inbuf = malloc(rows*cols*2); outbuf = malloc(rows*(cols+1)); if(!inbuf || !outbuf) { fputs(_("Out of memory"), stderr); - exit(1); - } - if (read(fd, inbuf, rows*cols*2) != rows*cols*2) { - fprintf(stderr, _("Error reading %s\n"), infile); - exit(1); + goto error; } + if (read(fd, inbuf, rows*cols*2) != rows*cols*2) + goto read_error; p = inbuf; q = outbuf; for(i=0; i= 0) + close(fd); exit(1); } -- 2.39.5