gawk-3.1.5-core.patch 653 B

12345678910111213141516171819202122232425262728293031
  1. fix an ugly core on a simple script
  2. http://lists.gnu.org/archive/html/bug-gnu-utils/2005-08/msg00040.html
  3. http://lists.gnu.org/archive/html/bug-gnu-utils/2005-08/msg00047.html
  4. --- gawk/io.c
  5. +++ gawk/io.c
  6. @@ -2480,9 +2480,12 @@
  7. {
  8. struct stat sbuf;
  9. struct open_hook *oh;
  10. + int iop_malloced = FALSE;
  11. - if (iop == NULL)
  12. + if (iop == NULL) {
  13. emalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc");
  14. + iop_malloced = TRUE;
  15. + }
  16. memset(iop, '\0', sizeof(IOBUF));
  17. iop->flag = 0;
  18. iop->fd = fd;
  19. @@ -2495,7 +2498,8 @@
  20. }
  21. if (iop->fd == INVALID_HANDLE) {
  22. - free(iop);
  23. + if (iop_malloced)
  24. + free(iop);
  25. return NULL;
  26. }
  27. if (isatty(iop->fd))