summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2012-10-13 09:06:18 -0700
committerDan Nicholson <dbn.lists@gmail.com>2012-10-13 09:06:18 -0700
commit1184d2085a2a4d4cb7cae4caf0a21eb495206722 (patch)
treefd69543b8654a62e0260f5b24d6e1447e2cbd9c7 /main.c
parenta14d489fbc17ddcb8481ef081abe0dacdc2a9a4a (diff)
downloadpkg-config-1184d2085a2a4d4cb7cae4caf0a21eb495206722.tar.gz
Don't crash on --print-variables when there are no variables
Apparently g_hash_table_foreach doesn't check for NULL input, so make sure we don't call it to print the variables if the variable list is empty. Freedesktop #54721
Diffstat (limited to 'main.c')
-rw-r--r--main.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/main.c b/main.c
index 385e43d..2aea422 100644
--- a/main.c
+++ b/main.c
@@ -580,9 +580,10 @@ main (int argc, char **argv)
while (tmp != NULL)
{
Package *pkg = tmp->data;
- g_hash_table_foreach(pkg->vars,
- &print_hashtable_key,
- NULL);
+ if (pkg->vars != NULL)
+ g_hash_table_foreach(pkg->vars,
+ &print_hashtable_key,
+ NULL);
tmp = g_slist_next (tmp);
if (tmp) printf ("\n");
}