diff options
Diffstat (limited to 'libio/genops.c')
-rw-r--r-- | libio/genops.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libio/genops.c b/libio/genops.c index 994ee9c0b1..6f20d49669 100644 --- a/libio/genops.c +++ b/libio/genops.c @@ -119,7 +119,8 @@ _IO_link_in (struct _IO_FILE_plus *fp) if (_IO_vtable_offset ((FILE *) fp) == 0) { fp->file._prevchain = (FILE **) &_IO_list_all; - _IO_list_all->file._prevchain = &fp->file._chain; + if (_IO_list_all != NULL) + _IO_list_all->file._prevchain = &fp->file._chain; } _IO_list_all = fp; #ifdef _IO_MTSAFE_IO @@ -661,7 +662,7 @@ _IO_sputbackc (FILE *fp, int c) { int result; - if (fp->_IO_read_ptr > fp->_IO_read_base + if (fp->_IO_read_ptr > fp->_IO_read_base && !_IO_in_backup (fp) && (unsigned char)fp->_IO_read_ptr[-1] == (unsigned char)c) { fp->_IO_read_ptr--; @@ -815,6 +816,12 @@ _IO_unbuffer_all (void) legacy = 1; #endif + /* Free up the backup area if it was ever allocated. */ + if (_IO_have_backup (fp)) + _IO_free_backup_area (fp); + if (!legacy && fp->_mode > 0 && _IO_have_wbackup (fp)) + _IO_free_wbackup_area (fp); + if (! (fp->_flags & _IO_UNBUFFERED) /* Iff stream is un-orientated, it wasn't used. */ && (legacy || fp->_mode != 0)) |