mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-12-23 01:59:49 +01:00
core: fix error handling in main
The error handling at the `error:` label tears down the whole state. Thus, the state needs to be fully initialized in order for the tear down to succeed. Currently, if e.g. `sd_bus_open_user()` fails, a `segfault` is triggered by the tear down. This commit adds individual tear down code that only touches stuff that until that point was successfully initialized.
This commit is contained in:
parent
b82d3fcc01
commit
a105e0e363
1 changed files with 6 additions and 3 deletions
|
@ -70,14 +70,15 @@ int main(int argc, char *argv[]) {
|
|||
ret = sd_bus_open_user(&bus);
|
||||
if (ret < 0) {
|
||||
logprint(ERROR, "dbus: failed to connect to user bus: %s", strerror(-ret));
|
||||
goto error;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
logprint(DEBUG, "dbus: connected");
|
||||
|
||||
struct wl_display *wl_display = wl_display_connect(NULL);
|
||||
if (!wl_display) {
|
||||
logprint(ERROR, "wayland: failed to connect to display");
|
||||
goto error;
|
||||
sd_bus_unref(bus);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
logprint(DEBUG, "wlroots: wl_display connected");
|
||||
|
||||
|
@ -85,7 +86,9 @@ int main(int argc, char *argv[]) {
|
|||
struct pw_loop *pw_loop = pw_loop_new(NULL);
|
||||
if (!pw_loop) {
|
||||
logprint(ERROR, "pipewire: failed to create loop");
|
||||
goto error;
|
||||
wl_display_disconnect(wl_display);
|
||||
sd_bus_unref(bus);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
logprint(DEBUG, "pipewire: pw_loop created");
|
||||
|
||||
|
|
Loading…
Reference in a new issue