[glib/mcatanzaro/#2597: 2/2] gproxyresolver: add asserts to ensure error is set
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/mcatanzaro/#2597: 2/2] gproxyresolver: add asserts to ensure error is set
- Date: Mon, 27 Jun 2022 20:12:35 +0000 (UTC)
commit 8e29865112a38dc57ce92830548c22d8dd05a2c7
Author: Michael Catanzaro <mcatanzaro redhat com>
Date: Mon Jun 27 15:10:25 2022 -0500
gproxyresolver: add asserts to ensure error is set
This will catch buggy implementations of GProxyResolver before they are
able to return bogus results to higher level code. In particular, if
g_proxy_resolver_lookup() returns NULL, it'd better set an error to
explain why.
gio/gproxyresolver.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gio/gproxyresolver.c b/gio/gproxyresolver.c
index 1787bf81f0..7ac64df633 100644
--- a/gio/gproxyresolver.c
+++ b/gio/gproxyresolver.c
@@ -158,6 +158,7 @@ g_proxy_resolver_lookup (GProxyResolver *resolver,
GError **error)
{
GProxyResolverInterface *iface;
+ gchar **proxy_uris;
g_return_val_if_fail (G_IS_PROXY_RESOLVER (resolver), NULL);
g_return_val_if_fail (uri != NULL, NULL);
@@ -171,7 +172,10 @@ g_proxy_resolver_lookup (GProxyResolver *resolver,
iface = G_PROXY_RESOLVER_GET_IFACE (resolver);
- return (* iface->lookup) (resolver, uri, cancellable, error);
+ proxy_uris = (* iface->lookup) (resolver, uri, cancellable, error);
+ if (proxy_uris == NULL && error != NULL)
+ g_assert (*error != NULL);
+ return proxy_uris;
}
/**
@@ -237,10 +241,14 @@ g_proxy_resolver_lookup_finish (GProxyResolver *resolver,
GError **error)
{
GProxyResolverInterface *iface;
+ gchar **proxy_uris;
g_return_val_if_fail (G_IS_PROXY_RESOLVER (resolver), NULL);
iface = G_PROXY_RESOLVER_GET_IFACE (resolver);
- return (* iface->lookup_finish) (resolver, result, error);
+ proxy_uris = (* iface->lookup_finish) (resolver, result, error);
+ if (proxy_uris == NULL && error != NULL)
+ g_assert (*error != NULL);
+ return proxy_uris;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]