Skip to content
Myr

wayland: {xdg_,}output_*(): free old strings before assigning new ones

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent f4da1eb · Browse files · 1 file+7 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+7 added−0 removed

  • other:+7 added−0 removed

1 file+7 added−0 removed

modified:wayland.c+7 added
932 unmodified lines
933 int32_t subpixel, const char *make, const char *model,934 int32_t transform)935{936 struct monitor *mon = data;937938 free(mon->make);939 free(mon->model);940941 mon->dim.mm.width = physical_width;942 mon->dim.mm.height = physical_height;943 mon->inch = sqrt(pow(mon->dim.mm.width, 2) + pow(mon->dim.mm.height, 2)) * 0.03937008;944 mon->make = make != NULL ? strdup(make) : NULL;945 mon->model = model != NULL ? strdup(model) : NULL;946 mon->subpixel = subpixel;947 mon->transform = transform;948949 output_update_ppi(mon);950}951952static void
69 unmodified lines
1022{1023 struct monitor *mon = data;1024 struct wayland *wayl = mon->wayl;10251026 free(mon->name);1027 mon->name = name != NULL ? strdup(name) : NULL;10281029 if (wayl->output_name != NULL &&1030 mon->name != NULL &&
7 unmodified lines
1038xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output,1039 const char *description)1040{1041 struct monitor *mon = data;1042 free(mon->description);1043 mon->description = description != NULL ? strdup(description) : NULL;1044}10451046static struct zxdg_output_v1_listener xdg_output_listener = {
574 unmodified lines