mirror of
https://github.com/labwc/labwc.git
synced 2026-06-13 14:33:18 -04:00
src/buffer.c: prevent creating invalid buffers
Testcase: set title of foot to an invisible string (here LTR) First one works and correctly sets the title, 2nd one crashes - printf "\x1b]0;\xe2\x80\x8e%s\x07" "some title" - printf "\x1b]0;\xe2\x80\x8e%s\x07" "" Reported-by: Domo via IRC
This commit is contained in:
parent
d2349c15a7
commit
a4526a16fc
2 changed files with 9 additions and 1 deletions
|
|
@ -82,6 +82,7 @@ font_buffer_create(struct lab_data_buffer **buffer, int max_width,
|
|||
cairo_pattern_t *bg_pattern, double scale)
|
||||
{
|
||||
if (string_null_or_empty(text)) {
|
||||
*buffer = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -91,6 +92,13 @@ font_buffer_create(struct lab_data_buffer **buffer, int max_width,
|
|||
height = computed_height;
|
||||
}
|
||||
|
||||
if (height <= 0 || width <= 0) {
|
||||
wlr_log(WLR_INFO, "Refusing to create invisible font buffer of %dx%d",
|
||||
width, height);
|
||||
*buffer = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
*buffer = buffer_create_cairo(width, height, scale);
|
||||
if (!*buffer) {
|
||||
wlr_log(WLR_ERROR, "Failed to create font buffer");
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ _create_buffer(struct scaled_buffer *scaled_buffer, double scale)
|
|||
&self->font, self->color, bg_pattern, scale);
|
||||
|
||||
if (!buffer) {
|
||||
wlr_log(WLR_ERROR, "font_buffer_create() failed");
|
||||
wlr_log(WLR_INFO, "font_buffer_create() failed");
|
||||
}
|
||||
|
||||
zfree_pattern(solid_bg_pattern);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue