summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2015-01-31 22:22:16 +0000
committerPhilip Withnall <philip.withnall@collabora.co.uk>2015-02-16 08:48:49 +0000
commitc74a18a0183f80d8ae97208de3ae657186ad4cd8 (patch)
treeaef3bcda576c5e9b953e02f06bdcf6f54ecd0254
parentd2dce55c971fc44cc327818b0341eb89f1243db6 (diff)
downloadgobject-introspection-c74a18a0183f80d8ae97208de3ae657186ad4cd8.tar.gz
girepository: Fix NULL return from g_irepository_get_dependencies()
If a typelib had no dependencies, g_irepository_get_dependencies() would return NULL, rather than an empty NULL-terminated vector. https://bugzilla.gnome.org/show_bug.cgi?id=743782
-rw-r--r--girepository/girepository.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/girepository/girepository.c b/girepository/girepository.c
index 931385ff..fb91afaa 100644
--- a/girepository/girepository.c
+++ b/girepository/girepository.c
@@ -253,6 +253,8 @@ build_typelib_key (const char *name, const char *source)
return g_string_free (str, FALSE);
}
+/* Note: Returns %NULL (not an empty %NULL-terminated array) if there are no
+ * dependencies. */
static char **
get_typelib_dependencies (GITypelib *typelib)
{
@@ -450,6 +452,7 @@ g_irepository_get_dependencies (GIRepository *repository,
const char *namespace)
{
GITypelib *typelib;
+ gchar **deps;
g_return_val_if_fail (namespace != NULL, NULL);
@@ -458,7 +461,12 @@ g_irepository_get_dependencies (GIRepository *repository,
typelib = get_registered (repository, namespace, NULL);
g_return_val_if_fail (typelib != NULL, NULL);
- return get_typelib_dependencies (typelib);
+ /* Ensure we always return a non-%NULL vector. */
+ deps = get_typelib_dependencies (typelib);
+ if (deps == NULL)
+ deps = g_strsplit ("", "|", 0);
+
+ return deps;
}
/**