about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-11-19 10:29:16 -0800
committerPetr Baudis <pasky@ucw.cz>2009-11-19 22:18:18 +0100
commit16b583ea7ec0b96c8908e6c5418836f74554329a (patch)
treec1f9a77e4e01c76bab761a76387e0ab6f8edf194
parent488e337a17866ebdb9ca6a07f91fc9fcf9f1c3db (diff)
downloadglibc-16b583ea7ec0b96c8908e6c5418836f74554329a.tar.gz
glibc-16b583ea7ec0b96c8908e6c5418836f74554329a.tar.xz
glibc-16b583ea7ec0b96c8908e6c5418836f74554329a.zip
Fix getwc* and putwc* on non-wide streams.
(cherry picked from commit df1934daa7788ca5f19d82efb02cdf9b9c495b1a)
-rw-r--r--ChangeLog5
-rw-r--r--libio/libio.h14
2 files changed, 13 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 34d486ae26..b6f77ff8ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-11-19  Ulrich Drepper  <drepper@redhat.com>
 
+	[BZ #10958]
+	* libio/libio.h (_IO_getwc_unlocked): Check for _wide_data being
+	initialized before using it.
+	(_IO_putwc_unlocked): Likewise.
+
 	[BZ #10918]
 	* sysdeps/unix/sysv/linux/bits/sched.h (__CPU_ISSET_S): Use __const
 	in cast to not throw away const-ness of parameters.
diff --git a/libio/libio.h b/libio/libio.h
index 643812f72b..3c9f2bd3e8 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1995,1997-2006,2007 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1995,1997-2006,2007,2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Per Bothner <bothner@cygnus.com>.
 
@@ -442,13 +442,15 @@ extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t);
 
 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
 # define _IO_getwc_unlocked(_fp) \
-  (_IO_BE ((_fp)->_wide_data->_IO_read_ptr >= (_fp)->_wide_data->_IO_read_end,\
-	   0) \
+  (_IO_BE ((_fp)->_wide_data == NULL					\
+	   || ((_fp)->_wide_data->_IO_read_ptr				\
+	       >= (_fp)->_wide_data->_IO_read_end), 0)			\
    ? __wuflow (_fp) : (_IO_wint_t) *(_fp)->_wide_data->_IO_read_ptr++)
 # define _IO_putwc_unlocked(_wch, _fp) \
-  (_IO_BE ((_fp)->_wide_data->_IO_write_ptr \
-	   >= (_fp)->_wide_data->_IO_write_end, 0) \
-   ? __woverflow (_fp, _wch) \
+  (_IO_BE ((_fp)->_wide_data == NULL					\
+	   || ((_fp)->_wide_data->_IO_write_ptr				\
+	       >= (_fp)->_wide_data->_IO_write_end), 0)			\
+   ? __woverflow (_fp, _wch)						\
    : (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch)))
 #endif