diff options
author | Benoit Gschwind <gschwind@gnu-log.net> | 2016-05-10 22:47:57 +0200 |
---|---|---|
committer | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2016-05-11 13:43:52 +0300 |
commit | 5375384545e4640acc342577798d30f632f5fc60 (patch) | |
tree | 76b58544ef7457a109a77137ec12ea02fe595651 /src/main.c | |
parent | 44e302b77dcc1f0fc0f88ff1f3ab6966b7789e85 (diff) | |
download | weston-5375384545e4640acc342577798d30f632f5fc60.tar.gz |
main: let load_wayland_backend() clean up on error
weston_wayland_backend_config_release() does not bother reinitializing
the structure, it simply frees what is there. This leads to a structure
containing garbage, which might be a surprise.
Require, that if load_wayland_backend_config() fails, the caller must
call weston_wayland_backend_config_release() regardless.
Signed-off-by: Benoit Gschwind <gschwind@gnu-log.net>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
[Pekka: rewrote commit message]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -1170,7 +1170,7 @@ load_wayland_backend_config(struct weston_compositor *compositor, int *argc, if (config->fullscreen) { oc = weston_wayland_backend_config_add_new_output(config); if (!oc) - goto err_outputs; + return -1; oc->width = width; oc->height = height; @@ -1197,7 +1197,7 @@ load_wayland_backend_config(struct weston_compositor *compositor, int *argc, oc = weston_wayland_backend_config_add_new_output(config); if (!oc) - goto err_outputs; + return -1; weston_wayland_output_config_init(oc, section, width, height, scale); @@ -1214,7 +1214,7 @@ load_wayland_backend_config(struct weston_compositor *compositor, int *argc, while (count > 0) { oc = weston_wayland_backend_config_add_new_output(config); if (!oc) - goto err_outputs; + return -1; oc->width = width; oc->height = height; @@ -1226,10 +1226,6 @@ load_wayland_backend_config(struct weston_compositor *compositor, int *argc, } return 0; - -err_outputs: - weston_wayland_backend_config_release(config); - return -1; } static int @@ -1241,6 +1237,7 @@ load_wayland_backend(struct weston_compositor *c, char const * backend, ret = load_wayland_backend_config(c, argc, argv, wc, &config); if(ret < 0) { + weston_wayland_backend_config_release(&config); return ret; } |