Mail Archives: djgpp-workers/1996/06/13/01:45:30
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 -