From f2042e132e589fb5915d1caa2072edbed21105f4 Mon Sep 17 00:00:00 2001 From: Michael Teyfel Date: Tue, 26 Sep 2017 17:12:08 +0200 Subject: [PATCH] ivi-shell: rework goto labels to avoid memory leaks Signed-off-by: Michael Teyfel --- ivi-shell/ivi-shell.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c index 54ab0419..e2761b9a 100644 --- a/ivi-shell/ivi-shell.c +++ b/ivi-shell/ivi-shell.c @@ -461,7 +461,6 @@ wet_shell_init(struct weston_compositor *compositor, int *argc, char *argv[]) { struct ivi_shell *shell; - int retval = -1; shell = zalloc(sizeof *shell); if (shell == NULL) @@ -478,13 +477,15 @@ wet_shell_init(struct weston_compositor *compositor, if (wl_global_create(compositor->wl_display, &ivi_application_interface, 1, shell, bind_ivi_application) == NULL) - goto out; + goto err_shell; ivi_layout_init_with_compositor(compositor); shell_add_bindings(compositor, shell); - retval = 0; + return IVI_SUCCEEDED; -out: - return retval; +err_shell: + free(shell); + + return IVI_FAILED; }