Date: Thu, 13 Jun 1996 08:40:36 +0200 (IST) From: Eli Zaretskii To: "Alexander V. Lukyanov" Cc: djgpp-workers AT delorie DOT com Subject: Re: Printer error In-Reply-To: <199606121548.TAA02454@video.yars.free.net> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 12 Jun 1996, Alexander V. Lukyanov wrote: > I made some modifications to my last flsbuf.c to fix the bug and btw > found a little hole in Eli's patch (see below). I have not yet tested > my new version, I'll post my patch when I'll do it. > > ! if ((base = f->_base) == NULL && (f->_flag & _IONBF) == 0) > ! { > ! size = _go32_info_block.size_of_transfer_buffer; > ! if ((f->_base = base = malloc (size)) == NULL) > ! f->_flag |= _IONBF; > ^^^ no buffer, the code under &_IOLBF can still crash Yes, that line should be these two lines instead: f->_flag |= _IONBF; f->_flag &= ~(_IOLBF | _IOFBF); Guess I never tested the patched version under no-memory conditions :-(. Btw, there are other places in that function (and probably also in its twin sister `filbuf.c') that turn on a bit like _IOLBF but don't bother to turn off the other buffering bits. I think these should be also corrected since otherwise the operation of the code depends on the order in which the various if clauses are tested.