summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRupert Swarbrick <rswarbrick@gmail.com>2010-06-10 00:34:22 +0100
committerShaun McCance <shaunm@gnome.org>2010-06-10 08:57:37 -0500
commit78f0d500bae2d95e29d09a1571aff7adf4a830be (patch)
tree4a6c9ec9e84cc09bd668180ef69f2be76fe64acd
parent8c60d0b4a158668202b4fde5c559d654c1afb7aa (diff)
downloadyelp-78f0d500bae2d95e29d09a1571aff7adf4a830be.tar.gz
Don't segfault on http:// uri's.
This was caused by uri's that came out as YELP_URI_DOCUMENT_TYPE_EXTERNAL getting a document_uri of NULL. Then this got inserted into several hashtables, whose hash function required (non-null) strings. A fix is to use the canonical uri if document_uri is NULL.
-rw-r--r--libyelp/yelp-uri.c17
-rw-r--r--libyelp/yelp-uri.h2
-rw-r--r--src/yelp-application.c2
3 files changed, 19 insertions, 2 deletions
diff --git a/libyelp/yelp-uri.c b/libyelp/yelp-uri.c
index ec5fcce6..9735b05d 100644
--- a/libyelp/yelp-uri.c
+++ b/libyelp/yelp-uri.c
@@ -309,12 +309,18 @@ resolve_async (YelpUri *uri)
}
else if (strchr (priv->res_arg, ':')) {
priv->tmptype = YELP_URI_DOCUMENT_TYPE_EXTERNAL;
- priv->fulluri = g_strdup (priv->res_arg);
}
else {
resolve_file_path (uri);
}
+ /* We _always_ want to have a non-null fulluri, so check for it
+ * having been set here and, if we can't think of something
+ * better, set it to res_arg. */
+ if (!priv->fulluri) {
+ priv->fulluri = g_strdup (priv->res_arg);
+ }
+
done:
g_idle_add ((GSourceFunc) resolve_final, uri);
}
@@ -368,6 +374,15 @@ yelp_uri_get_document_uri (YelpUri *uri)
YelpUriPrivate *priv = GET_PRIV (uri);
if (priv->doctype == YELP_URI_DOCUMENT_TYPE_UNRESOLVED)
return NULL;
+
+ /* There's some client code where it makes sense to want a
+ * document uri, whether or not it conforms to a scheme we really
+ * understand. For example, we might want to look up whether the
+ * given page is currently being visited. */
+ if ((!priv->docuri) && priv->fulluri) {
+ return g_strdup (priv->fulluri);
+ }
+
return g_strdup (priv->docuri);
}
diff --git a/libyelp/yelp-uri.h b/libyelp/yelp-uri.h
index 81612619..13aa73bb 100644
--- a/libyelp/yelp-uri.h
+++ b/libyelp/yelp-uri.h
@@ -73,6 +73,8 @@ void yelp_uri_resolve (YelpUri *uri);
gboolean yelp_uri_is_resolved (YelpUri *uri);
YelpUriDocumentType yelp_uri_get_document_type (YelpUri *uri);
+/* Both of these functions return a non-null answer, provided that
+ * the uri has been resolved. */
gchar * yelp_uri_get_canonical_uri (YelpUri *uri);
gchar * yelp_uri_get_document_uri (YelpUri *uri);
diff --git a/src/yelp-application.c b/src/yelp-application.c
index 071e0c1c..4ce1ae6f 100644
--- a/src/yelp-application.c
+++ b/src/yelp-application.c
@@ -450,7 +450,7 @@ application_uri_resolved (YelpUri *uri,
doc_uri = yelp_uri_get_document_uri (uri);
- if (data->new)
+ if (data->new || !doc_uri)
window = NULL;
else
window = g_hash_table_lookup (priv->windows_by_document, doc_uri);