[Spice-devel] [PATCH spice-gtk v3 4/7] spice-uri: Reset SpiceUri before parsing
Pavel Grunt
pgrunt at redhat.com
Thu May 19 16:38:06 UTC 2016
Avoid using old values after parsing a new uri.
Related: rhbz#1335239
---
src/spice-uri.c | 7 +++++++
tests/test-spice-uri.c | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/spice-uri.c b/src/spice-uri.c
index 3bdb502..04ea3cb 100644
--- a/src/spice-uri.c
+++ b/src/spice-uri.c
@@ -105,6 +105,13 @@ gboolean spice_uri_parse(SpiceURI *self, const gchar *_uri, GError **error)
size_t len;
g_return_val_if_fail(self != NULL, FALSE);
+
+ self->scheme = NULL;
+ self->hostname = NULL;
+ self->port = 0;
+ self->user = NULL;
+ self->password = NULL;
+
g_return_val_if_fail(_uri != NULL, FALSE);
uri = dup = g_strdup(_uri);
diff --git a/tests/test-spice-uri.c b/tests/test-spice-uri.c
index e8cfcc9..1b14dbb 100644
--- a/tests/test-spice-uri.c
+++ b/tests/test-spice-uri.c
@@ -36,10 +36,10 @@ static void test_spice_uri_ipv4(void)
{"http://127.0.0.1:port", "http", "127.0.0.1", 3128, NULL, NULL}, /* invalid port */
};
const struct test_case valid_test_cases[] = {
- {"http://127.0.0.1/", "http", "127.0.0.1", 3128, NULL, NULL},
+ {"http://user:password@host:80", "http", "host", 80, "user", "password"},
+ {"http://127.0.0.1/", "http", "127.0.0.1", 3128, NULL, NULL}, /* reset user & password */
{"https://127.0.0.1", "https", "127.0.0.1", 3129, NULL, NULL},
{"127.0.0.1", "http", "127.0.0.1", 3128, NULL, NULL},
- {"http://user:password@host:80", "http", "host", 80, "user", "password"},
};
guint i;
--
2.8.2
More information about the Spice-devel
mailing list