mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-03 01:40:17 -05:00
wayland: {xdg_,}output_*(): free old strings before assigning new ones
Defensive programming; output_geometry() etc are typically only called once for an output instance. But let’s ensure we’re not leaking memory if it’s called more than once.
This commit is contained in:
parent
e299b1d9f4
commit
44a166dde8
1 changed files with 7 additions and 0 deletions
|
|
@ -359,6 +359,10 @@ output_geometry(void *data, struct wl_output *wl_output, int32_t x, int32_t y,
|
||||||
int32_t transform)
|
int32_t transform)
|
||||||
{
|
{
|
||||||
struct monitor *mon = data;
|
struct monitor *mon = data;
|
||||||
|
|
||||||
|
free(mon->make);
|
||||||
|
free(mon->model);
|
||||||
|
|
||||||
mon->dim.mm.width = physical_width;
|
mon->dim.mm.width = physical_width;
|
||||||
mon->dim.mm.height = physical_height;
|
mon->dim.mm.height = physical_height;
|
||||||
mon->inch = sqrt(pow(mon->dim.mm.width, 2) + pow(mon->dim.mm.height, 2)) * 0.03937008;
|
mon->inch = sqrt(pow(mon->dim.mm.width, 2) + pow(mon->dim.mm.height, 2)) * 0.03937008;
|
||||||
|
|
@ -366,6 +370,7 @@ output_geometry(void *data, struct wl_output *wl_output, int32_t x, int32_t y,
|
||||||
mon->model = model != NULL ? xstrdup(model) : NULL;
|
mon->model = model != NULL ? xstrdup(model) : NULL;
|
||||||
mon->subpixel = subpixel;
|
mon->subpixel = subpixel;
|
||||||
mon->transform = transform;
|
mon->transform = transform;
|
||||||
|
|
||||||
output_update_ppi(mon);
|
output_update_ppi(mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -434,6 +439,7 @@ xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
struct monitor *mon = data;
|
struct monitor *mon = data;
|
||||||
|
free(mon->name);
|
||||||
mon->name = name != NULL ? xstrdup(name) : NULL;
|
mon->name = name != NULL ? xstrdup(name) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -442,6 +448,7 @@ xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output,
|
||||||
const char *description)
|
const char *description)
|
||||||
{
|
{
|
||||||
struct monitor *mon = data;
|
struct monitor *mon = data;
|
||||||
|
free(mon->description);
|
||||||
mon->description = description != NULL ? xstrdup(description) : NULL;
|
mon->description = description != NULL ? xstrdup(description) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue