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)
This commit is contained in:
Ignacio Casal Quinteiro 2015-10-23 10:34:50 +02:00
parent 3bb8294e00
commit 50d704ab8f

View File

@ -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,