diff --git a/Makefile.am b/Makefile.am
index 3d687d2..0ee9d2c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -54,6 +54,7 @@ EXTRA_DIST = pkg.m4 \
tests/lib1/isystem.pc \
tests/lib1/depgraph-break.pc \
tests/lib1/cflags-whitespace.pc \
+ tests/lib1/cflags-whitespace-trailing.pc \
tests/lib1/provides.pc \
tests/lib1/provides-request-simple.pc \
tests/test_env.sh \
diff --git a/README.md b/README.md
index c8e80ab..1df2ead 100644
--- a/README.md
+++ b/README.md
@@ -88,7 +88,7 @@ to make this determination themselves.
## release tarballs
-Release tarballs are available at .
+Release tarballs are available at .
Please do not use the github tarballs as they are not pristine (instead generated by github everytime
a download occurs).
diff --git a/libpkgconf/fragment.c b/libpkgconf/fragment.c
index 032b006..e596a10 100644
--- a/libpkgconf/fragment.c
+++ b/libpkgconf/fragment.c
@@ -105,6 +105,9 @@ pkgconf_fragment_add(pkgconf_list_t *list, const char *string, unsigned int flag
{
pkgconf_fragment_t *frag;
+ if (*string == '\0')
+ return;
+
if (!pkgconf_fragment_is_special(string))
{
frag = calloc(sizeof(pkgconf_fragment_t), 1);
diff --git a/libpkgconf/pkg.c b/libpkgconf/pkg.c
index 02392e8..1ef2aac 100644
--- a/libpkgconf/pkg.c
+++ b/libpkgconf/pkg.c
@@ -348,6 +348,7 @@ pkgconf_pkg_free(pkgconf_pkg_t *pkg)
pkgconf_dependency_free(&pkg->requires);
pkgconf_dependency_free(&pkg->requires_private);
pkgconf_dependency_free(&pkg->conflicts);
+ pkgconf_dependency_free(&pkg->provides);
pkgconf_fragment_free(&pkg->cflags);
pkgconf_fragment_free(&pkg->cflags_private);
diff --git a/tests/lib1/cflags-whitespace-trailing.pc b/tests/lib1/cflags-whitespace-trailing.pc
new file mode 100644
index 0000000..2e66035
--- /dev/null
+++ b/tests/lib1/cflags-whitespace-trailing.pc
@@ -0,0 +1,4 @@
+Name: CFlags Trailing Whitespace Bug
+Description: Demonstrates problems with -I with spaces
+Version: 1
+Cflags: -I/usr/include -I/usr/include/foo
diff --git a/tests/run.sh.in b/tests/run.sh.in
index 79e9f6c..4af05c7 100644
--- a/tests/run.sh.in
+++ b/tests/run.sh.in
@@ -291,6 +291,8 @@ run_test "PKG_CONFIG_PATH='${selfdir}/lib1' PKG_CONFIG_SYSROOT_DIR='/test' ${1}
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' PKG_CONFIG_SYSROOT_DIR='/test' ${1} --cflags cflags-whitespace" \
"-I /test/opt/bad/include"
+run_test "PKG_CONFIG_PATH='${selfdir}/lib1' PKG_CONFIG_SYSTEM_INCLUDE_PATH='/usr/include' ${1} --cflags cflags-whitespace-trailing" \
+ "-I/usr/include/foo"
# 10) tests for Provides system
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --print-provides provides" \