cache: handle pkg being NULL on pkg_cache_add()/pkg_cache_remove()

pull/48/head
William Pitcock 2013-03-15 16:50:30 -05:00
parent 1a49758792
commit c04a64352f
2 changed files with 8 additions and 0 deletions

View File

@ -49,6 +49,9 @@ pkg_cache_lookup(const char *id)
void void
pkg_cache_add(pkg_t *pkg) pkg_cache_add(pkg_t *pkg)
{ {
if (pkg == NULL)
return;
pkg_ref(pkg); pkg_ref(pkg);
pkg_node_insert(&pkg->cache_iter, pkg, &pkg_cache); pkg_node_insert(&pkg->cache_iter, pkg, &pkg_cache);
@ -62,6 +65,9 @@ pkg_cache_add(pkg_t *pkg)
void void
pkg_cache_remove(pkg_t *pkg) pkg_cache_remove(pkg_t *pkg)
{ {
if (pkg == NULL)
return;
pkg_node_delete(&pkg->cache_iter, &pkg_cache); pkg_node_delete(&pkg->cache_iter, &pkg_cache);
} }

View File

@ -64,6 +64,8 @@ run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags --libs 'foo' '>' '1.2'
'-lfoo' '-I/usr/include/foo' '-fPIC' '-lfoo' '-I/usr/include/foo' '-fPIC'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists nonexistant; echo \$?" \ run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists nonexistant; echo \$?" \
'1' '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 \$?" \ run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists 'foo > 1.2'; echo \$?" \
'0' '0'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists 'foo > 1.2.3'; echo \$?" \ run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists 'foo > 1.2.3'; echo \$?" \