[glib/glib-2-46] win32: make sure bytes_read/written is set to 0 on error



commit 24366e159894c0b6d5895642f9687f01ac2c5ec7
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Fri Oct 23 10:34:50 2015 +0200

    win32: make sure bytes_read/written is set to 0 on error
    
    If we fail to PeekMessage or PostMessage we should make sure
    that the output parameter bytes_read/written is set 0 instead
    of being left uninitialized. This fixes an assertion in the io
    channel call where the following invariant is checked:
    (status == G_IO_STATUS_NORMAL) || (read_size == 0)

 glib/giowin32.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/glib/giowin32.c b/glib/giowin32.c
index 171fb68..b839e94 100644
--- a/glib/giowin32.c
+++ b/glib/giowin32.c
@@ -1033,7 +1033,9 @@ g_io_win32_msg_read (GIOChannel *channel,
 {
   GIOWin32Channel *win32_channel = (GIOWin32Channel *)channel;
   MSG msg;               /* In case of alignment problems */
-  
+
+  *bytes_read = 0;
+
   if (count < sizeof (MSG))
     {
       g_set_error_literal (err, G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_INVAL,
@@ -1062,7 +1064,9 @@ g_io_win32_msg_write (GIOChannel  *channel,
 {
   GIOWin32Channel *win32_channel = (GIOWin32Channel *)channel;
   MSG msg;
-  
+
+  *bytes_written = 0;
+
   if (count != sizeof (MSG))
     {
       g_set_error_literal (err, G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_INVAL,


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