]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
libio: Initialize _total_written for all kinds of streams
authorTulio Magno Quites Machado Filho <tuliom@redhat.com>
Fri, 31 Jan 2025 13:26:22 +0000 (10:26 -0300)
committerTulio Magno Quites Machado Filho <tuliom@redhat.com>
Thu, 13 Feb 2025 19:34:54 +0000 (16:34 -0300)
Move the initialization code to a general place instead of keeping it
specific to file-backed streams.

Fixes: 596a61cf6b (libio: Start to return errors when flushing fwrite's buffer [BZ #29459], 2025-01-28)
Reported-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Arjun Shankar <arjun@redhat.com>
libio/fileops.c
libio/genops.c

index 1a192b7512409b50636cd0ae2f476a77bfffbebb..a59e248142682f8e9649b658fcbeb2058b7e9f29 100644 (file)
@@ -113,7 +113,6 @@ _IO_new_file_init_internal (struct _IO_FILE_plus *fp)
 
   _IO_link_in (fp);
   fp->file._fileno = -1;
-  fp->file._total_written = 0;
 }
 
 /* External version of _IO_new_file_init_internal which switches off
index e4378ca48fee7a36930e33331da5644ec6509c13..c3178d9a97acc57ce897502e0672d8d512a34fe0 100644 (file)
@@ -611,6 +611,7 @@ _IO_no_init (FILE *fp, int flags, int orientation,
        stream.  */
     fp->_wide_data = (struct _IO_wide_data *) -1L;
   fp->_freeres_list = NULL;
+  fp->_total_written = 0;
 }
 
 int