diff options
author | Richard Hughes <richard@hughsie.com> | 2015-02-04 09:23:52 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2015-02-04 09:23:54 +0000 |
commit | ba68a8a3788a7f3ff3945abd03459a1af909ab46 (patch) | |
tree | 113db1a2fa04fb5a803536b101fac40c216db290 /libappstream-builder/asb-self-test.c | |
parent | eb7992290c39efed28179efa9b3a607f9d3637ed (diff) | |
download | appstream-glib-ba68a8a3788a7f3ff3945abd03459a1af909ab46.tar.gz |
Fix a crash when more than one thread tries to ensure the same package
This can happen when a package is itself an extra package of another, at the
same time being a valid application itself. This is probably a packaging bug,
but crashing isn't nice either.
Diffstat (limited to 'libappstream-builder/asb-self-test.c')
-rw-r--r-- | libappstream-builder/asb-self-test.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libappstream-builder/asb-self-test.c b/libappstream-builder/asb-self-test.c index b196cba..687bb21 100644 --- a/libappstream-builder/asb-self-test.c +++ b/libappstream-builder/asb-self-test.c @@ -155,6 +155,29 @@ asb_test_package_rpm_func (void) asb_package_set_config (pkg, "test", "dave2"); g_assert_cmpstr (asb_package_get_config (pkg, "test"), ==, "dave2"); + /* clear */ + asb_package_clear (pkg, + ASB_PACKAGE_ENSURE_DEPS | + ASB_PACKAGE_ENSURE_FILES); + g_assert (asb_package_get_filelist (pkg) == NULL); + g_assert_cmpint (asb_package_get_deps(pkg)->len, ==, 0); + + /* clear, ensure, ensure, clear, check, clear */ + asb_package_clear (pkg, ASB_PACKAGE_ENSURE_DEPS); + g_assert_cmpint (asb_package_get_deps(pkg)->len, ==, 0); + ret = asb_package_ensure (pkg, ASB_PACKAGE_ENSURE_DEPS, &error); + g_assert_no_error (error); + g_assert (ret); + g_assert_cmpint (asb_package_get_deps(pkg)->len, ==, 3); + ret = asb_package_ensure (pkg, ASB_PACKAGE_ENSURE_DEPS, &error); + g_assert_no_error (error); + g_assert (ret); + g_assert_cmpint (asb_package_get_deps(pkg)->len, ==, 3); + asb_package_clear (pkg, ASB_PACKAGE_ENSURE_DEPS); + g_assert_cmpint (asb_package_get_deps(pkg)->len, ==, 3); + asb_package_clear (pkg, ASB_PACKAGE_ENSURE_DEPS); + g_assert_cmpint (asb_package_get_deps(pkg)->len, ==, 0); + /* compare */ g_assert_cmpint (asb_package_compare (pkg, pkg), ==, 0); |