mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 06:32:10 +01:00
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
This commit is contained in:
parent
270a954b54
commit
5046dfc85d
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user