[PATCH weston v3 01/15] ivi-shell: rework goto labels to avoid memory leaks

Michael Teyfel mteyfel at de.adit-jv.com
Tue Apr 10 08:59:53 UTC 2018


Signed-off-by: Michael Teyfel <mteyfel at de.adit-jv.com>
---
 ivi-shell/ivi-shell.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
index 51e13a0..6497376 100644
--- a/ivi-shell/ivi-shell.c
+++ b/ivi-shell/ivi-shell.c
@@ -469,7 +469,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)
@@ -481,22 +480,27 @@ wet_shell_init(struct weston_compositor *compositor,
 	wl_signal_add(&compositor->destroy_signal, &shell->destroy_listener);
 
 	if (input_panel_setup(shell) < 0)
-		goto out;
+		goto err_shell;
 
 	shell->text_backend = text_backend_init(compositor);
 	if (!shell->text_backend)
-		goto out;
+		goto err_shell;
 
 	if (wl_global_create(compositor->wl_display,
 			     &ivi_application_interface, 1,
 			     shell, bind_ivi_application) == NULL)
-		goto out;
+		goto err_text_backend;
 
 	ivi_layout_init_with_compositor(compositor);
 	shell_add_bindings(compositor, shell);
 
-	retval = 0;
+	return IVI_SUCCEEDED;
 
-out:
-	return retval;
+err_text_backend:
+	text_backend_destroy(shell->text_backend);
+
+err_shell:
+	free(shell);
+
+	return IVI_FAILED;
 }
-- 
2.7.4



More information about the wayland-devel mailing list