[glib] GSocket: fix garbled error messages on windows



commit 5046dfc85d7df95d7f8c87e3b41d9152bc50549a
Author: Dan Winship <danw gnome org>
Date:   Mon Apr 12 10:21:20 2010 -0400

    GSocket: fix garbled error messages on windows
    
    socket_strerror() was assuming all "strerror" messages are shorter
    than 128 bytes, which is certainly true on Linux, but apparently not
    on Windows.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=615494

 gio/gsocket.c |   17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)
---
diff --git a/gio/gsocket.c b/gio/gsocket.c
index 93208d1..fb35f32 100644
--- a/gio/gsocket.c
+++ b/gio/gsocket.c
@@ -212,20 +212,13 @@ socket_strerror (int err)
 #ifndef G_OS_WIN32
   return g_strerror (err);
 #else
-  static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT;
-  char *buf, *msg;
-
-  buf = g_static_private_get (&msg_private);
-  if (!buf)
-    {
-      buf = g_new (gchar, 128);
-      g_static_private_set (&msg_private, buf, g_free);
-    }
+  static GStaticPrivate last_msg = G_STATIC_PRIVATE_INIT;
+  char *msg;
 
   msg = g_win32_error_message (err);
-  strncpy (buf, msg, 128);
-  g_free (msg);
-  return buf;
+  g_static_private_set (&last_msg, msg, g_free);
+
+  return msg;
 #endif
 }
 



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