}
int len = strlen(dir) + strlen(filename) + 2;
char *buffer = calloc(1, len);
+ if (!buffer) {
+ return NULL;
+ }
strcat(buffer, dir);
strcat(buffer, "/");
strcat(buffer, filename);
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
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);