diff --git a/src/config/session.c b/src/config/session.c index cadb6834..f861e785 100644 --- a/src/config/session.c +++ b/src/config/session.c @@ -79,6 +79,9 @@ build_path(const char *dir, const char *filename) } int len = strlen(dir) + strlen(filename) + 2; char *buffer = calloc(1, len); + if (!buffer) { + return NULL; + } strcat(buffer, dir); strcat(buffer, "/"); strcat(buffer, filename); @@ -101,16 +104,24 @@ update_activation_env(const char *env_keys) const char *systemd = "systemctl --user import-environment "; cmd = calloc(1, strlen(dbus) + strlen(env_keys) + 1); - strcat(cmd, dbus); - strcat(cmd, env_keys); - spawn_async_no_shell(cmd); - free(cmd); + if (!cmd) { + wlr_log(WLR_ERROR, "Failed to allocate memory for dbus env update"); + } else { + strcat(cmd, dbus); + strcat(cmd, env_keys); + spawn_async_no_shell(cmd); + free(cmd); + } cmd = calloc(1, strlen(systemd) + strlen(env_keys) + 1); - strcat(cmd, systemd); - strcat(cmd, env_keys); - spawn_async_no_shell(cmd); - free(cmd); + if (!cmd) { + wlr_log(WLR_ERROR, "Failed to allocate memory for systemd env update"); + } else { + strcat(cmd, systemd); + strcat(cmd, env_keys); + spawn_async_no_shell(cmd); + free(cmd); + } } void @@ -148,6 +159,10 @@ session_autostart_init(const char *dir) wlr_log(WLR_INFO, "run autostart file %s", autostart); int len = strlen(autostart) + 4; char *cmd = calloc(1, len); + if (!cmd) { + wlr_log(WLR_ERROR, "Failed to allocate memory for autostart command"); + goto out; + } strcat(cmd, "sh "); strcat(cmd, autostart); spawn_async_no_shell(cmd);