aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2021-01-02 20:07:47 +0100
committerIlia Bozhinov <ammen99@gmail.com>2021-01-05 12:22:20 +0100
commit8b90d5e17f4a09caf27e0cdd34bb155f4272d0e7 (patch)
tree0570940075c21759d247139f784ee4b99be73aa9
parentabcab0331fc0537de83da3e5bff4a6787b3786a8 (diff)
toplevel-management: handle strdup failure
Sending a NULL string to a client would be a violation of the protocol.
-rw-r--r--types/wlr_foreign_toplevel_management_v1.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/types/wlr_foreign_toplevel_management_v1.c b/types/wlr_foreign_toplevel_management_v1.c
index 558e7997..56052096 100644
--- a/types/wlr_foreign_toplevel_management_v1.c
+++ b/types/wlr_foreign_toplevel_management_v1.c
@@ -198,6 +198,10 @@ void wlr_foreign_toplevel_handle_v1_set_title(
struct wlr_foreign_toplevel_handle_v1 *toplevel, const char *title) {
free(toplevel->title);
toplevel->title = strdup(title);
+ if (toplevel->title == NULL) {
+ wlr_log(WLR_ERROR, "failed to allocate memory for toplevel title");
+ return;
+ }
struct wl_resource *resource;
wl_resource_for_each(resource, &toplevel->resources) {
@@ -211,6 +215,10 @@ void wlr_foreign_toplevel_handle_v1_set_app_id(
struct wlr_foreign_toplevel_handle_v1 *toplevel, const char *app_id) {
free(toplevel->app_id);
toplevel->app_id = strdup(app_id);
+ if (toplevel->app_id == NULL) {
+ wlr_log(WLR_ERROR, "failed to allocate memory for toplevel app_id");
+ return;
+ }
struct wl_resource *resource;
wl_resource_for_each(resource, &toplevel->resources) {