diff --git a/cache.c b/cache.c index 40c6f54..43bb5c6 100644 --- a/cache.c +++ b/cache.c @@ -49,6 +49,9 @@ pkg_cache_lookup(const char *id) void pkg_cache_add(pkg_t *pkg) { + if (pkg == NULL) + return; + pkg_ref(pkg); pkg_node_insert(&pkg->cache_iter, pkg, &pkg_cache); @@ -62,6 +65,9 @@ pkg_cache_add(pkg_t *pkg) void pkg_cache_remove(pkg_t *pkg) { + if (pkg == NULL) + return; + pkg_node_delete(&pkg->cache_iter, &pkg_cache); } diff --git a/tests/run.sh.in b/tests/run.sh.in index 6ba296f..f6a53a9 100644 --- a/tests/run.sh.in +++ b/tests/run.sh.in @@ -64,6 +64,8 @@ run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags --libs 'foo' '>' '1.2' '-lfoo' '-I/usr/include/foo' '-fPIC' run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists nonexistant; echo \$?" \ '1' +run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} nonexistant; echo \$?" \ + '1' run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists 'foo > 1.2'; echo \$?" \ '0' run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists 'foo > 1.2.3'; echo \$?" \