From 0262b8251d0025734b452f2fa47d7d6cb0d5b2fd Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Fri, 19 May 2017 23:33:49 -0500 Subject: [PATCH] libpkgconf: pkgconf_pkg_find(): correctly handle failure from pkgconf_pkg_new_from_file() --- libpkgconf/pkg.c | 8 +++++--- tests/lib1/malformed-1.pc | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 tests/lib1/malformed-1.pc diff --git a/libpkgconf/pkg.c b/libpkgconf/pkg.c index 7e697d3..ddb3806 100644 --- a/libpkgconf/pkg.c +++ b/libpkgconf/pkg.c @@ -616,9 +616,11 @@ pkgconf_pkg_find(pkgconf_client_t *client, const char *name) PKGCONF_TRACE(client, "%s is a file", name); pkg = pkgconf_pkg_new_from_file(client, name, f); - pkgconf_path_add(pkg_get_parent_dir(pkg), &client->dir_list, true); - - return pkg; + if (pkg != NULL) + { + pkgconf_path_add(pkg_get_parent_dir(pkg), &client->dir_list, true); + return pkg; + } } } diff --git a/tests/lib1/malformed-1.pc b/tests/lib1/malformed-1.pc new file mode 100644 index 0000000..4f4a700 --- /dev/null +++ b/tests/lib1/malformed-1.pc @@ -0,0 +1,2 @@ +prefix=/usr\nName: GKrellM\nDescription: Extensible GTK system monitoring application\nVersion: 2.3.7\nRequires: gtk+-2.0 >= 2.4.0\nCflags: -I/usr/include\n +