# --- T2-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # T2 SDE: package/.../gawk/invalid-free.patch # Copyright (C) 2004 - 2005 The T2 SDE Project # # More information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # --- T2-COPYRIGHT-NOTE-END --- If the pointer is not ours, we must not free it. - Rene Rebe --- gawk-3.1.5/io.c 2005-07-26 20:07:43.000000000 +0200 +++ gawk-3.1.5-fixed/io.c 2005-09-10 16:27:17.000000000 +0200 @@ -2480,9 +2480,12 @@ { struct stat sbuf; struct open_hook *oh; + int need_free = 0; - if (iop == NULL) + if (iop == NULL) { emalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc"); + need_free = 1; + } memset(iop, '\0', sizeof(IOBUF)); iop->flag = 0; iop->fd = fd; @@ -2495,7 +2498,8 @@ } if (iop->fd == INVALID_HANDLE) { - free(iop); + if (need_free) + free(iop); return NULL; } if (isatty(iop->fd))