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>
dev
Benoit Gschwind 9 years ago committed by Pekka Paalanen
parent 44e302b77d
commit 5375384545
  1. 11
      src/main.c

@ -1170,7 +1170,7 @@ load_wayland_backend_config(struct weston_compositor *compositor, int *argc,
if (config->fullscreen) { if (config->fullscreen) {
oc = weston_wayland_backend_config_add_new_output(config); oc = weston_wayland_backend_config_add_new_output(config);
if (!oc) if (!oc)
goto err_outputs; return -1;
oc->width = width; oc->width = width;
oc->height = height; 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); oc = weston_wayland_backend_config_add_new_output(config);
if (!oc) if (!oc)
goto err_outputs; return -1;
weston_wayland_output_config_init(oc, section, width, weston_wayland_output_config_init(oc, section, width,
height, scale); height, scale);
@ -1214,7 +1214,7 @@ load_wayland_backend_config(struct weston_compositor *compositor, int *argc,
while (count > 0) { while (count > 0) {
oc = weston_wayland_backend_config_add_new_output(config); oc = weston_wayland_backend_config_add_new_output(config);
if (!oc) if (!oc)
goto err_outputs; return -1;
oc->width = width; oc->width = width;
oc->height = height; oc->height = height;
@ -1226,10 +1226,6 @@ load_wayland_backend_config(struct weston_compositor *compositor, int *argc,
} }
return 0; return 0;
err_outputs:
weston_wayland_backend_config_release(config);
return -1;
} }
static int 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); ret = load_wayland_backend_config(c, argc, argv, wc, &config);
if(ret < 0) { if(ret < 0) {
weston_wayland_backend_config_release(&config);
return ret; return ret;
} }

Loading…
Cancel
Save