summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2010-08-27 19:19:37 +0100
committerDaniel P. Berrange <berrange@redhat.com>2010-08-27 19:19:37 +0100
commitc43af5932df1d3bcbb32498e54df9bbdb044970e (patch)
treef5f72e0b8c8bc841b6469923f68961738b37e413 /test
parenta45e4dda3ae9a18cc6b0333d1ff935e7a97635e4 (diff)
Ensure all GList return values are duplicated
To avoid exposing callers to the internal implementation, ensure all returned GList * values are shallow-copied. All callers must g_list_free the value. The elements are not copied. * osinfo/osinfo_db.c, osinfo/osinfo_db.c, osinfo/osinfo_filter.c, osinfo/osinfo_osfilter.c: Copy all GList return values. * test/test-entity.c, test/test-filter.c, test/test-osfilter.c: Free GList values
Diffstat (limited to 'test')
-rw-r--r--test/test-entity.c5
-rw-r--r--test/test-filter.c2
-rw-r--r--test/test-osfilter.c4
3 files changed, 11 insertions, 0 deletions
diff --git a/test/test-entity.c b/test/test-entity.c
index 6197864..96d7c5d 100644
--- a/test/test-entity.c
+++ b/test/test-entity.c
@@ -79,6 +79,7 @@ START_TEST(test_single_prop_value)
fail_unless(values != NULL, "Entity param value list was empty");
fail_unless(values->next == NULL, "Entity param value list has too many values");
fail_unless(g_strcmp0(values->data, "world") == 0, "Entity param list value was not 'world'");
+ g_list_free(values);
g_object_unref(ent);
}
@@ -111,6 +112,7 @@ START_TEST(test_multi_prop_value)
fail_unless(g_strcmp0(values->data, "world") == 0, "Entity param list first value was not 'world'");
fail_unless(g_strcmp0(values->next->data, "fred") == 0, "Entity param list second value was not 'fred'");
fail_unless(g_strcmp0(values->next->next->data, "elephant") == 0, "Entity param list third was not 'elephant'");
+ g_list_free(values);
g_object_unref(ent);
}
@@ -158,16 +160,19 @@ START_TEST(test_multi_props)
fail_unless(values != NULL, "Entity param value list was empty");
fail_unless(values->next == NULL, "Entity param value list has too many values");
fail_unless(g_strcmp0(values->data, "world") == 0, "Entity param list value was not 'world'");
+ g_list_free(values);
values = osinfo_entity_get_param_value_list(ent, "fish");
fail_unless(values != NULL, "Entity param value list was empty");
fail_unless(values->next == NULL, "Entity param value list has too many values");
fail_unless(g_strcmp0(values->data, "food") == 0, "Entity param list value was not 'food'");
+ g_list_free(values);
values = osinfo_entity_get_param_value_list(ent, "kevin");
fail_unless(values != NULL, "Entity param value list was empty");
fail_unless(values->next == NULL, "Entity param value list has too many values");
fail_unless(g_strcmp0(values->data, "bacon") == 0, "Entity param list value was not 'bacon'");
+ g_list_free(values);
g_object_unref(ent);
}
diff --git a/test/test-filter.c b/test/test-filter.c
index aa386c8..18b2d00 100644
--- a/test/test-filter.c
+++ b/test/test-filter.c
@@ -39,6 +39,7 @@ START_TEST(test_basic)
fail_unless(values != NULL, "missing value");
fail_unless(g_strcmp0(values->data, "pci") == 0, "missing value");
fail_unless(values->next == NULL, "too many keys");
+ g_list_free(values);
values = osinfo_filter_get_constraint_values(filter, "class");
fail_unless(values != NULL, "missing value");
@@ -46,6 +47,7 @@ START_TEST(test_basic)
fail_unless(g_strcmp0(values->data, "audio") == 0, "missing value");
fail_unless(g_strcmp0(values->next->data, "network") == 0, "missing value");
fail_unless(values->next->next == NULL, "too many values");
+ g_list_free(values);
g_object_unref(dev);
g_object_unref(filter);
diff --git a/test/test-osfilter.c b/test/test-osfilter.c
index b210176..ac3f78a 100644
--- a/test/test-osfilter.c
+++ b/test/test-osfilter.c
@@ -19,6 +19,7 @@ START_TEST(test_basic)
fail_unless(tmp != NULL, "Unexpected missing OS");
fail_unless(tmp->data == os1, "Derived OS is OS 1");
fail_unless(tmp->next == NULL, "Too many derived OS");
+ g_list_free(tmp);
tmp = osinfo_osfilter_get_os_constraint_values(osfilter,
OSINFO_OS_RELATIONSHIP_CLONES);
@@ -33,6 +34,7 @@ START_TEST(test_basic)
fail_unless(tmp->next != NULL, "Not enough derived OS");
fail_unless(tmp->next->data == os1, "Derived OS is OS 1");
fail_unless(tmp->next->next == NULL, "Too many derived OS");
+ g_list_free(tmp);
osinfo_osfilter_add_os_constraint(osfilter, OSINFO_OS_RELATIONSHIP_UPGRADES, os1);
tmp = osinfo_osfilter_get_os_constraint_values(osfilter,
@@ -40,6 +42,7 @@ START_TEST(test_basic)
fail_unless(tmp != NULL, "Unexpected missing OS");
fail_unless(tmp->data == os1, "Derived OS is OS 1");
fail_unless(tmp->next == NULL, "Too many derived OS");
+ g_list_free(tmp);
osinfo_osfilter_add_os_constraint(osfilter, OSINFO_OS_RELATIONSHIP_CLONES, os1);
tmp = osinfo_osfilter_get_os_constraint_values(osfilter,
@@ -47,6 +50,7 @@ START_TEST(test_basic)
fail_unless(tmp != NULL, "Unexpected missing OS");
fail_unless(tmp->data == os1, "Derived OS is OS 1");
fail_unless(tmp->next == NULL, "Too many derived OS");
+ g_list_free(tmp);
g_object_unref(os2);
g_object_unref(os1);