summaryrefslogtreecommitdiffstats
path: root/collection
diff options
context:
space:
mode:
Diffstat (limited to 'collection')
-rw-r--r--collection/collection.c2
-rw-r--r--collection/collection_ut.c11
2 files changed, 12 insertions, 1 deletions
diff --git a/collection/collection.c b/collection/collection.c
index ce0bbec..d836aa4 100644
--- a/collection/collection.c
+++ b/collection/collection.c
@@ -574,7 +574,7 @@ int col_insert_item_into_current(struct collection_item *collection,
/* Move to the right position counting */
while (idx > 0) {
idx--;
- parent = parent->next;
+ if (parent->next) parent = parent->next;
}
item->next = parent->next;
parent->next = item;
diff --git a/collection/collection_ut.c b/collection/collection_ut.c
index abf0f11..1b48fc0 100644
--- a/collection/collection_ut.c
+++ b/collection/collection_ut.c
@@ -1354,6 +1354,9 @@ int insert_extract_test(void)
(error = col_insert_str_property(col, NULL, COL_DSP_END,
NULL, 0, COL_INSERT_NOCHECK,
"property1", "value1", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_INDEX,
+ NULL, 1, COL_INSERT_NOCHECK,
+ "second", "second", 0)) ||
(error = col_insert_str_property(col, NULL, COL_DSP_END,
NULL, 0, COL_INSERT_NOCHECK,
"property2", "value2", 0)) ||
@@ -1437,6 +1440,14 @@ int insert_extract_test(void)
((verbose) && (error = col_debug_collection(col2, COL_TRAVERSE_DEFAULT))) ||
+ (error = col_extract_item(col, NULL, COL_DSP_FRONT,
+ NULL, 0, 0, &item)) ||
+
+ (error = col_insert_item(col2, NULL, item, COL_DSP_FRONT,
+ NULL, 0, COL_INSERT_NOCHECK)) ||
+
+ ((verbose) && (error = col_debug_collection(col2, COL_TRAVERSE_DEFAULT))) ||
+
(error = col_extract_item(col, NULL, COL_DSP_END,
NULL, 0, 0, &item)) ||