launcher: fix leak in launcher_weston_launch_connect()
Leak found running drm-smoke-test with ASan. Do not forget to free the launcher before returning when we can't open the launcher fd. Also, just set 'out = launcher' after all error paths, otherwise we give the caller a stale pointer. Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This commit is contained in:
committed by
Daniel Stone
parent
bd4f250d48
commit
d42fa30d14
@@ -323,12 +323,15 @@ launcher_weston_launch_connect(struct weston_launcher **out, struct weston_compo
|
||||
return -ENOMEM;
|
||||
|
||||
launcher->base.iface = &launcher_weston_launch_iface;
|
||||
* (struct launcher_weston_launch **) out = launcher;
|
||||
launcher->compositor = compositor;
|
||||
launcher->drm_fd = -1;
|
||||
launcher->deferred_deactivate = 0;
|
||||
launcher->fd = launcher_weston_environment_get_fd("WESTON_LAUNCHER_SOCK");
|
||||
if (launcher->fd != -1) {
|
||||
if (launcher->fd == -1) {
|
||||
free(launcher);
|
||||
return -1;
|
||||
}
|
||||
|
||||
launcher->tty = launcher_weston_environment_get_fd("WESTON_TTY_FD");
|
||||
/* We don't get a chance to read out the original kb
|
||||
* mode for the tty, so just hard code K_UNICODE here
|
||||
@@ -346,10 +349,9 @@ launcher_weston_launch_connect(struct weston_launcher **out, struct weston_compo
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
* (struct launcher_weston_launch **) out = launcher;
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user