bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: freadseek


From: Bruno Haible
Subject: Re: freadseek
Date: Sun, 30 Mar 2008 10:32:43 +0100
User-agent: KMail/1.5.4

Eric Blake wrote:
> makes the
> test-freadseek test pass on cygwin (at first I thought it was another
> instance of ungetc undefined behavior, but on closer inspection, your
> definition of freadseek is well-defined without any reliance on fflush -
> the real bug was that freadseek was incrementing the in-memory pointer
> beyond the bounds of the ungetc buffer).

Thanks. I had forgotten to update freadseek after cleaning up the semantics
of freadahead and freadptr.

But now 'buffered' is an uninitialized variable (see the specification in
lib/freadptr.h). Fixing it like this:


2008-03-30  Bruno Haible  <address@hidden>

        * lib/freadseek.c (freadseek): Don't ignore the return value of
        freadptr.

*** lib/freadseek.c.orig        2008-03-30 11:31:46.000000000 +0200
--- lib/freadseek.c     2008-03-30 11:31:16.000000000 +0200
***************
*** 34,45 ****
      return 0;
  
    /* Increment the in-memory pointer.  This is very cheap (no system calls).  
*/
!   freadptr (fp, &buffered);
!   if (buffered > 0)
      {
        size_t increment = (buffered < offset ? buffered : offset);
  
!       /* Keep this code in sync with freadahead and freadptr!  */
  #if defined _IO_ferror_unlocked     /* GNU libc, BeOS */
        fp->_IO_read_ptr += increment;
  #elif defined __sferror             /* FreeBSD, NetBSD, OpenBSD, MacOS X, 
Cygwin */
--- 34,44 ----
      return 0;
  
    /* Increment the in-memory pointer.  This is very cheap (no system calls).  
*/
!   if (freadptr (fp, &buffered) != NULL && buffered > 0)
      {
        size_t increment = (buffered < offset ? buffered : offset);
  
!       /* Keep this code in sync with freadptr!  */
  #if defined _IO_ferror_unlocked     /* GNU libc, BeOS */
        fp->_IO_read_ptr += increment;
  #elif defined __sferror             /* FreeBSD, NetBSD, OpenBSD, MacOS X, 
Cygwin */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]