soup_uri_new: do not allow invalid URIs to be returned, except via soup_uri_new ...
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Tue, 10 Jan 2012 13:51:31 +0000 (13:51 +0000)
committerDan Winship <danw@gnome.org>
Mon, 6 Feb 2012 22:12:26 +0000 (17:12 -0500)
Also document the possible NULL return.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=667637
Bug-NB: NB#294977

libsoup/soup-uri.c

index 0e4c31c..d2d752a 100644 (file)
@@ -405,7 +405,8 @@ soup_uri_new_with_base (SoupURI *base, const char *uri_string)
  * call at least soup_uri_set_scheme() and soup_uri_set_path(), since
  * those fields are required.)
  *
- * Return value: a #SoupURI, or %NULL.
+ * Return value: a #SoupURI, or %NULL if the given string was found to be
+ *  invalid.
  **/
 SoupURI *
 soup_uri_new (const char *uri_string)
@@ -418,7 +419,7 @@ soup_uri_new (const char *uri_string)
        uri = soup_uri_new_with_base (NULL, uri_string);
        if (!uri)
                return NULL;
-       if (!uri->scheme) {
+       if (!SOUP_URI_IS_VALID (uri)) {
                soup_uri_free (uri);
                return NULL;
        }