diff options
author | Calvin Lee <cyrus296@gmail.com> | 2017-08-16 09:23:21 +0200 |
---|---|---|
committer | Calvin Lee <cyrus296@gmail.com> | 2017-08-16 09:23:21 +0200 |
commit | 901c14c409e6e8143ade06a7478241e558cfb79c (patch) | |
tree | 8e83344aeadb70c3449baa663d02d7013c542d62 /backend/multi | |
parent | 19d6442f52743d50d10c796d7146f58c251f67fe (diff) |
Prevent alloc errors from crashing in `list_t`
This commit changes the `list_t` api so that alloc errors can be
detected and worked around. Also fixes errors not found in 5cc7342
Diffstat (limited to 'backend/multi')
-rw-r--r-- | backend/multi/backend.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/backend/multi/backend.c b/backend/multi/backend.c index 290b9678..33b26a0a 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -120,6 +120,12 @@ void wlr_multi_backend_add(struct wlr_backend *_multi, wlr_log(L_ERROR, "Could not add backend: allocation failed"); return; } + if (list_add(multi->backends, sub) == -1) { + wlr_log(L_ERROR, "Could not add backend: allocation failed"); + free(sub); + return; + } + sub->backend = backend; sub->container = &multi->backend; @@ -137,8 +143,6 @@ void wlr_multi_backend_add(struct wlr_backend *_multi, wl_signal_add(&backend->events.input_remove, &sub->input_remove); wl_signal_add(&backend->events.output_add, &sub->output_add); wl_signal_add(&backend->events.output_remove, &sub->output_remove); - - list_add(multi->backends, sub); } struct wlr_session *wlr_multi_get_session(struct wlr_backend *_backend) { |