source: clfs-sysroot/patches/gawk-3.1.5-segfault_fix-1.patch@ fd94a60

Last change on this file since fd94a60 was 8f3d581, checked in by Joe Ciccone <jciccone@…>, 18 years ago

Add all of the patches needed for clfs-sysroot.

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[8f3d581]1Submitted By: Matthew Burgess <matthew@linuxfromscratch.org>
2Date: 2005-09-24
3Initial Package Version: 3.1.5
4Upstream Status: From Upstream
5Origin: http://lists.gnu.org/archive/html/bug-gnu-utils/2005-08/msg00047.html
6Description: Fixes a bug which causes gawk to segfault when operating on a non-existent file.
7
8diff -Naur gawk-3.1.5.orig/io.c gawk-3.1.5/io.c
9--- gawk-3.1.5.orig/io.c 2005-07-26 18:07:43.000000000 +0000
10+++ gawk-3.1.5/io.c 2005-09-24 14:43:13.771380264 +0000
11@@ -2480,9 +2480,12 @@
12 {
13 struct stat sbuf;
14 struct open_hook *oh;
15+ int iop_malloced = FALSE;
16
17- if (iop == NULL)
18+ if (iop == NULL) {
19 emalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc");
20+ iop_malloced = TRUE;
21+ }
22 memset(iop, '\0', sizeof(IOBUF));
23 iop->flag = 0;
24 iop->fd = fd;
25@@ -2495,7 +2498,8 @@
26 }
27
28 if (iop->fd == INVALID_HANDLE) {
29- free(iop);
30+ if (iop_malloced)
31+ free(iop);
32 return NULL;
33 }
34 if (isatty(iop->fd))
35@@ -2503,7 +2507,7 @@
36 iop->readsize = iop->size = optimal_bufsize(iop->fd, & sbuf);
37 iop->sbuf = sbuf;
38 if (do_lint && S_ISREG(sbuf.st_mode) && sbuf.st_size == 0)
39- lintwarn(_("data file `%s' is empty"), name);
40+ lintwarn(_("data file `%s' is empty"), name);
41 errno = 0;
42 iop->count = iop->scanoff = 0;
43 emalloc(iop->buf, char *, iop->size += 2, "iop_alloc");
Note: See TracBrowser for help on using the repository browser.