[Spice-devel] [PATCH spice-gtk v3 4/7] spice-uri: Reset SpiceUri before parsing
Pavel Grunt
pgrunt at redhat.com
Fri May 20 09:07:58 UTC 2016
On Fri, 2016-05-20 at 10:24 +0200, Victor Toso wrote:
> Hi,
>
> On Thu, May 19, 2016 at 06:38:06PM +0200, Pavel Grunt wrote:
> > Avoid using old values after parsing a new uri.
>
> A test case with re-using the SpiceURI could be handy
>
All the tests are reusing SpiceURI
> >
> > 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_clear_pointer to avoid leaks?
sure, thanks a lot, stupid me /o\
Pavel
>
> > 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
> >
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list