Fix a memory leak in g_strerror

If g_locale_to_utf8 sets a GError, it must be freed.
This commit is contained in:
Dan Carpenter 2023-03-02 15:28:46 +01:00
parent 6c22a5ee2b
commit 774d8bd914

View File

@ -1369,7 +1369,10 @@ g_strerror (gint errnum)
{
msg = g_locale_to_utf8 (msg, -1, NULL, NULL, &error);
if (error)
g_print ("%s\n", error->message);
{
g_print ("%s\n", error->message);
g_error_free (error);
}
}
else if (msg == (const gchar *)buf)
msg = g_strdup (buf);