mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
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.
This commit is contained in:
parent
1738fad172
commit
8e29865112
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user