mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
scaled-scene-buffer: guard against negative sizes
This commit is contained in:
parent
6305cc0f78
commit
849fd7a96f
4 changed files with 13 additions and 2 deletions
|
|
@ -79,6 +79,9 @@ struct scaled_icon_buffer *
|
|||
scaled_icon_buffer_create(struct wlr_scene_tree *parent, struct server *server,
|
||||
int width, int height)
|
||||
{
|
||||
assert(parent);
|
||||
assert(width >= 0 && height >= 0);
|
||||
|
||||
struct scaled_scene_buffer *scaled_buffer = scaled_scene_buffer_create(
|
||||
parent, &impl, /* drop_buffer */ true);
|
||||
struct scaled_icon_buffer *self = znew(*self);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,10 @@ struct scaled_img_buffer *
|
|||
scaled_img_buffer_create(struct wlr_scene_tree *parent, struct lab_img *img,
|
||||
int width, int height)
|
||||
{
|
||||
assert(parent);
|
||||
assert(img);
|
||||
assert(width >= 0 && height >= 0);
|
||||
|
||||
struct scaled_scene_buffer *scaled_buffer = scaled_scene_buffer_create(
|
||||
parent, &impl, /* drop_buffer */ true);
|
||||
struct scaled_img_buffer *self = znew(*self);
|
||||
|
|
|
|||
|
|
@ -95,14 +95,16 @@ struct scaled_rect_buffer *scaled_rect_buffer_create(
|
|||
/* TODO: support rounded corners for menus and OSDs */
|
||||
|
||||
assert(parent);
|
||||
assert(width >= 0 && height >= 0);
|
||||
|
||||
struct scaled_rect_buffer *self = znew(*self);
|
||||
struct scaled_scene_buffer *scaled_buffer = scaled_scene_buffer_create(
|
||||
parent, &impl, /* drop_buffer */ true);
|
||||
scaled_buffer->data = self;
|
||||
self->scaled_buffer = scaled_buffer;
|
||||
self->scene_buffer = scaled_buffer->scene_buffer;
|
||||
self->width = MAX(width, 1);
|
||||
self->height = MAX(height, 1);
|
||||
self->width = width;
|
||||
self->height = height;
|
||||
self->border_width = border_width;
|
||||
memcpy(self->fill_color, fill_color, sizeof(self->fill_color));
|
||||
memcpy(self->border_color, border_color, sizeof(self->border_color));
|
||||
|
|
|
|||
|
|
@ -227,6 +227,9 @@ scaled_scene_buffer_request_update(struct scaled_scene_buffer *self,
|
|||
int width, int height)
|
||||
{
|
||||
assert(self);
|
||||
assert(width >= 0);
|
||||
assert(height >= 0);
|
||||
|
||||
struct scaled_scene_buffer_cache_entry *cache_entry, *cache_entry_tmp;
|
||||
wl_list_for_each_safe(cache_entry, cache_entry_tmp, &self->cache, link) {
|
||||
_cache_entry_destroy(cache_entry, self->drop_buffer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue