mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
map: make _insert_at() fail on a removed item
You are only supposed to use _insert_new()/_remove() or _insert_at() on the map, If we detect a _insert_at() to a removed item, return an error because else we might corrupt the free list. Update unit test accordingly.
This commit is contained in:
parent
d5825b8551
commit
c07f0ccb71
2 changed files with 3 additions and 29 deletions
|
|
@ -188,7 +188,6 @@ PWTEST(map_insert_at_free)
|
|||
int data[3] = {1, 2, 3};
|
||||
int new_data = 4;
|
||||
int *ptr[3] = {&data[0], &data[1], &data[3]};
|
||||
int *new_ptr = &new_data;
|
||||
int idx[3];
|
||||
int rc;
|
||||
|
||||
|
|
@ -225,21 +224,7 @@ PWTEST(map_insert_at_free)
|
|||
}
|
||||
|
||||
rc = pw_map_insert_at(&map, item_idx, &new_data);
|
||||
pwtest_neg_errno_ok(rc);
|
||||
pwtest_ptr_eq(new_ptr, pw_map_lookup(&map, item_idx));
|
||||
|
||||
if (before_idx != SKIP && before_idx != item_idx) {
|
||||
rc = pw_map_insert_at(&map, before_idx, &ptr[before_idx]);
|
||||
pwtest_neg_errno_ok(rc);
|
||||
pwtest_ptr_eq(&ptr[before_idx], pw_map_lookup(&map, before_idx));
|
||||
}
|
||||
|
||||
if (after_idx != SKIP && after_idx != item_idx) {
|
||||
rc = pw_map_insert_at(&map, after_idx, &ptr[after_idx]);
|
||||
pwtest_neg_errno_ok(rc);
|
||||
pwtest_ptr_eq(&ptr[after_idx], pw_map_lookup(&map, after_idx));
|
||||
}
|
||||
|
||||
pwtest_neg_errno(rc, -EINVAL);
|
||||
pw_map_clear(&map);
|
||||
|
||||
return PWTEST_PASS;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue