bug in setvbuf

Mike Wescott wescott at sauron.Columbia.NCR.COM
Wed Feb 22 13:33:58 AEST 1989


In the SysVr3v2 code, setvbuf(fp,buf,type,size) when called with buf==NULL will
malloc() a buffer of size, free()ing the old one if _IOMYBUF is set in
fp->_flags.  As used elsewhere in the stdio code _IOMYBUF is used to indicate
that the buffer has been malloc()ed in the stdio code and should be free()ed at
fclose() or when setvbuf(), or setbuf() overrides.

_IOMYBUF is NOT set in setvbuf when the buffer is malloc()ed. Shouldn't it be?
If not, how would the space get freed? No, I don't think the programmer should
do a free(fp->_base).
-- 
	-Mike Wescott
	 mike.wescott at ncrcae.Columbia.NCR.COM



More information about the Comp.unix.wizards mailing list