|
|
719066 |
From 810efc113dc90a60689295ea99de61eee918c46f Mon Sep 17 00:00:00 2001
|
|
|
719066 |
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
|
|
|
719066 |
Date: Thu, 22 Oct 2020 13:23:25 +0200
|
|
|
719066 |
Subject: [PATCH] Use already implemented clear for COMPS_HSList
|
|
|
719066 |
(RhBug:1888343)
|
|
|
719066 |
|
|
|
719066 |
Instead of reimplementing clear for COMPS_HSList use comps_hslist_clear.
|
|
|
719066 |
The crash was caused by dangling pointers first and last in the
|
|
|
719066 |
COMPS_HSList (rt->subnodes) struct, function comps_hslist_clear clears
|
|
|
719066 |
them out properly.
|
|
|
719066 |
|
|
|
719066 |
= changelog =
|
|
|
719066 |
msg: Fix a crash when clearing COMPS_ObjRTree
|
|
|
719066 |
type: bugfix
|
|
|
719066 |
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1888343
|
|
|
719066 |
---
|
|
|
719066 |
libcomps/src/comps_objradix.c | 15 ++-------------
|
|
|
719066 |
libcomps/src/python/tests/__test.py | 10 ++++++++++
|
|
|
719066 |
2 files changed, 12 insertions(+), 13 deletions(-)
|
|
|
719066 |
|
|
|
719066 |
diff --git a/libcomps/src/comps_objradix.c b/libcomps/src/comps_objradix.c
|
|
|
719066 |
index 840592a..111ddbc 100644
|
|
|
719066 |
--- a/libcomps/src/comps_objradix.c
|
|
|
719066 |
+++ b/libcomps/src/comps_objradix.c
|
|
|
719066 |
@@ -611,20 +611,9 @@ void comps_objrtree_unset(COMPS_ObjRTree * rt, const char * key) {
|
|
|
719066 |
}
|
|
|
719066 |
|
|
|
719066 |
void comps_objrtree_clear(COMPS_ObjRTree * rt) {
|
|
|
719066 |
- COMPS_HSListItem *it, *oldit;
|
|
|
719066 |
if (rt==NULL) return;
|
|
|
719066 |
- if (rt->subnodes == NULL) return;
|
|
|
719066 |
- oldit = rt->subnodes->first;
|
|
|
719066 |
- it = (oldit)?oldit->next:NULL;
|
|
|
719066 |
- for (;it != NULL; it=it->next) {
|
|
|
719066 |
- comps_object_destroy(oldit->data);
|
|
|
719066 |
- free(oldit);
|
|
|
719066 |
- oldit = it;
|
|
|
719066 |
- }
|
|
|
719066 |
- if (oldit) {
|
|
|
719066 |
- comps_object_destroy(oldit->data);
|
|
|
719066 |
- free(oldit);
|
|
|
719066 |
- }
|
|
|
719066 |
+ comps_hslist_clear(rt->subnodes);
|
|
|
719066 |
+ rt->len = 0;
|
|
|
719066 |
}
|
|
|
719066 |
|
|
|
719066 |
inline COMPS_HSList* __comps_objrtree_all(COMPS_ObjRTree * rt, char keyvalpair) {
|
|
|
719066 |
diff --git a/libcomps/src/python/tests/__test.py b/libcomps/src/python/tests/__test.py
|
|
|
719066 |
index 9cb957a..2b321e3 100644
|
|
|
719066 |
--- a/libcomps/src/python/tests/__test.py
|
|
|
719066 |
+++ b/libcomps/src/python/tests/__test.py
|
|
|
719066 |
@@ -986,6 +986,16 @@ def test_envs(self):
|
|
|
719066 |
|
|
|
719066 |
_f([x.name for x in env.option_ids], option_ids)
|
|
|
719066 |
|
|
|
719066 |
+ #@unittest.skip("")
|
|
|
719066 |
+ def test_clear_for_COMPS_ObjRTree_such_as_group_or_category_namy_by_lang(self):
|
|
|
719066 |
+ comps = libcomps.Comps()
|
|
|
719066 |
+ ret = comps.fromxml_f("comps/f21-rawhide-comps.xml")
|
|
|
719066 |
+
|
|
|
719066 |
+ env = comps.categories[0].name_by_lang.clear()
|
|
|
719066 |
+ env = comps.groups[0].name_by_lang.clear()
|
|
|
719066 |
+
|
|
|
719066 |
+ self.assertEqual(str(comps.categories[0].name_by_lang), u'{}')
|
|
|
719066 |
+ self.assertEqual(str(comps.groups[0].name_by_lang), u'{}')
|
|
|
719066 |
|
|
|
719066 |
#@unittest.skip("")
|
|
|
719066 |
def test_xml_options(self):
|