mirror of
https://gitlab.freedesktop.org/pkg-config/pkg-config.git
synced 2025-12-20 05:30:03 +01:00
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
This commit is contained in:
parent
a14d489fbc
commit
1184d2085a
4 changed files with 13 additions and 5 deletions
|
|
@ -49,4 +49,5 @@ EXTRA_DIST = \
|
|||
non-l-required.pc \
|
||||
circular-1.pc \
|
||||
circular-2.pc \
|
||||
circular-3.pc
|
||||
circular-3.pc \
|
||||
no-variables.pc
|
||||
|
|
|
|||
|
|
@ -11,7 +11,10 @@ run_test --version
|
|||
RESULT=1.0.0
|
||||
run_test --modversion simple
|
||||
|
||||
# --print-variables
|
||||
# --print-variables, make sure having no variables doesn't crash
|
||||
RESULT=""
|
||||
run_test --print-variables no-variables
|
||||
|
||||
RESULT="exec_prefix
|
||||
prefix
|
||||
libdir
|
||||
|
|
|
|||
3
check/no-variables.pc
Normal file
3
check/no-variables.pc
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Name: No Variables
|
||||
Description: Test package having no variables to check --print-variables
|
||||
Version: 4.2
|
||||
7
main.c
7
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");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue