[glib] resolver: Return early if URI is invalid
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] resolver: Return early if URI is invalid
- Date: Thu, 1 Feb 2018 14:59:44 +0000 (UTC)
commit e889fb2a7f7d6b9d1bfa5a9a704be9537925b47b
Author: Bastien Nocera <hadess hadess net>
Date: Fri Jan 6 13:33:25 2017 +0100
resolver: Return early if URI is invalid
https://bugzilla.gnome.org/show_bug.cgi?id=772989
gio/gproxyresolver.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/gio/gproxyresolver.c b/gio/gproxyresolver.c
index 082274e..bd9528d 100644
--- a/gio/gproxyresolver.c
+++ b/gio/gproxyresolver.c
@@ -27,8 +27,10 @@
#include "gasyncresult.h"
#include "gcancellable.h"
+#include "gtask.h"
#include "giomodule.h"
#include "giomodule-priv.h"
+#include "gnetworkingprivate.h"
/**
* SECTION:gproxyresolver
@@ -145,6 +147,9 @@ g_proxy_resolver_lookup (GProxyResolver *resolver,
g_return_val_if_fail (G_IS_PROXY_RESOLVER (resolver), NULL);
g_return_val_if_fail (uri != NULL, NULL);
+ if (!_g_uri_parse_authority (uri, NULL, NULL, NULL, error))
+ return NULL;
+
iface = G_PROXY_RESOLVER_GET_IFACE (resolver);
return (* iface->lookup) (resolver, uri, cancellable, error);
@@ -171,10 +176,19 @@ g_proxy_resolver_lookup_async (GProxyResolver *resolver,
gpointer user_data)
{
GProxyResolverInterface *iface;
+ GError *error = NULL;
g_return_if_fail (G_IS_PROXY_RESOLVER (resolver));
g_return_if_fail (uri != NULL);
+ if (!_g_uri_parse_authority (uri, NULL, NULL, NULL, &error))
+ {
+ g_task_report_error (resolver, callback, user_data,
+ g_proxy_resolver_lookup_async,
+ g_steal_pointer (&error));
+ return;
+ }
+
iface = G_PROXY_RESOLVER_GET_IFACE (resolver);
(* iface->lookup_async) (resolver, uri, cancellable, callback, user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]