This mess goes completely to hell when a reallocation is necessary. Not only is realloc() called with the wrong arguments; sptable was also incremented before (so that it does not point anymore to the allocated memory). And after a realloc, the free(ip) will free the wrong memory.
Welcome to IRAF.
The file
fgwrite.c
is obviously buggy in the memory allocation ofslines
.slines
is globally defined: https://github.com/iraf-community/fitsutil/blob/a85313c562dd446c2e75f1f8835f971f5354f740/src/fgwrite.c#L112main(argc, argv)
https://github.com/iraf-community/fitsutil/blob/a85313c562dd446c2e75f1f8835f971f5354f740/src/fgwrite.c#L269-L272 …toc_card()
andlist_mef()
is called indirectly https://github.com/iraf-community/fitsutil/blob/a85313c562dd446c2e75f1f8835f971f5354f740/src/fgwrite.c#L303-L306toc_card (in, fh, ftype, hd_cards, level, usize)
https://github.com/iraf-community/fitsutil/blob/a85313c562dd446c2e75f1f8835f971f5354f740/src/fgwrite.c#L1463-L1468__
list_mef(fd, usize)
__ https://github.com/iraf-community/fitsutil/blob/a85313c562dd446c2e75f1f8835f971f5354f740/src/fgwrite.c#L1585-L1589This mess goes completely to hell when a reallocation is necessary. Not only is
realloc()
called with the wrong arguments;sptable
was also incremented before (so that it does not point anymore to the allocated memory). And after a realloc, thefree(ip)
will free the wrong memory. Welcome to IRAF.