mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-03-21 05:34:09 -04:00
xwayland: fix wl_array rollback when adding selection targets
Ensure mime_types and mime_types_atoms remain in sync when wl_array_add() fails. Roll back the partially added entry and free the allocated mime type to avoid leaks and inconsistent state.
This commit is contained in:
parent
90f9f59041
commit
d362ed1eb9
1 changed files with 3 additions and 1 deletions
|
|
@ -381,13 +381,15 @@ static bool source_get_targets(struct wlr_xwm_selection *selection,
|
||||||
free(mime_type);
|
free(mime_type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*mime_type_ptr = mime_type;
|
|
||||||
|
|
||||||
xcb_atom_t *atom_ptr =
|
xcb_atom_t *atom_ptr =
|
||||||
wl_array_add(mime_types_atoms, sizeof(*atom_ptr));
|
wl_array_add(mime_types_atoms, sizeof(*atom_ptr));
|
||||||
if (atom_ptr == NULL) {
|
if (atom_ptr == NULL) {
|
||||||
|
mime_types->size -= sizeof(*mime_type_ptr);
|
||||||
|
free(mime_type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*mime_type_ptr = mime_type;
|
||||||
*atom_ptr = value[i];
|
*atom_ptr = value[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue