delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/06/13/01:45:30

Date: Thu, 13 Jun 1996 08:40:36 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: "Alexander V. Lukyanov" <lav AT video DOT yars DOT free DOT net>
Cc: djgpp-workers AT delorie DOT com
Subject: Re: Printer error
In-Reply-To: <199606121548.TAA02454@video.yars.free.net>
Message-Id: <Pine.SUN.3.91.960613081648.8264D-100000@is>
Mime-Version: 1.0

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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019