glib2/backport-gsocketclient-Crash-on-error-if-error-is-missing.patch
shirely16 a3d31ddf3c synchronous community patch
(cherry picked from commit 5fb95aa15490a21b390e53a88c1b8b052971e504)
2021-05-21 15:56:45 +08:00

60 lines
2.1 KiB
Diff

From 14f7b5e590f6adc3207019227586d20848274654 Mon Sep 17 00:00:00 2001
From: Michael Catanzaro <mcatanzaro@gnome.org>
Date: Mon, 5 Oct 2020 12:32:32 -0500
Subject: [PATCH 0990/1095] gsocketclient: Crash on error if error is missing
We should never return unknown errors to the application. This would be
a glib bug.
I don't think it's currently possible to hit these cases, so asserts
should be OK. For this to happen, either (a) a GSocketAddressEnumerator
would have to return NULL on its first enumeration, without returning an
error, or (b) there would have to be a bug in our GSocketClient logic.
Either way, if such a bug were to exist, it would be better to surface
it rather than hide it.
These changes are actually going to be effectively undone in a
subsequent commit, as I'm refactoring the error handling, but the commit
history is a bit nicer with two separate commits, so let's go with two.
reason:Crash on error if error is missing
Conflict:NA
Reference:https://github.com/GNOME/glib/commit/14f7b5e590f6adc3207019227586d20848274654
---
gio/gsocketclient.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/gio/gsocketclient.c b/gio/gsocketclient.c
index 9df8f29..fb68c09 100644
--- a/gio/gsocketclient.c
+++ b/gio/gsocketclient.c
@@ -1053,8 +1053,9 @@ g_socket_client_connect (GSocketClient *client,
g_propagate_error (error, last_error);
}
else
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- _("Unknown error on connect"));
+ {
+ g_assert_not_reached ();
+ }
break;
}
@@ -1879,10 +1880,9 @@ g_socket_client_enumerator_callback (GObject *object,
error = data->last_error;
data->last_error = NULL;
}
- else if (!error)
+ else
{
- g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
- _("Unknown error on connect"));
+ g_assert (error);
}
complete_connection_with_error (data, error);
--
1.8.3.1