mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
set: prevent possible segfault when keycode 0 is released
lab_set_remove() didn't expect keycode 0 as the first branch (set->values[i] == value) was taken over and over.
This commit is contained in:
parent
b58f8dab21
commit
cacf11fc90
1 changed files with 3 additions and 8 deletions
|
|
@ -29,16 +29,11 @@ lab_set_add(struct lab_set *set, uint32_t value)
|
|||
void
|
||||
lab_set_remove(struct lab_set *set, uint32_t value)
|
||||
{
|
||||
bool shifting = false;
|
||||
|
||||
for (int i = 0; i < LAB_SET_MAX_SIZE; ++i) {
|
||||
for (int i = 0; i < set->size; ++i) {
|
||||
if (set->values[i] == value) {
|
||||
--set->size;
|
||||
shifting = true;
|
||||
}
|
||||
if (shifting) {
|
||||
set->values[i] = i < LAB_SET_MAX_SIZE - 1
|
||||
? set->values[i + 1] : 0;
|
||||
set->values[i] = set->values[set->size];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue