Skip to content

Commit

Permalink
screenshot: clean up xdpw request
Browse files Browse the repository at this point in the history
The xdpw request creates an object on the bus.
Not removing it means that the next call to method_pick_color() will
fail as the old object is still around.

Also make sure to clean up in error cases.
  • Loading branch information
t-8ch authored and emersion committed May 18, 2024
1 parent 32b009a commit 0776565
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/screenshot/screenshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ static int method_screenshot(sd_bus_message *msg, void *data,
const char path[] = "/tmp/out.png";
const char uri[] = "file:///tmp/out.png";
if (interactive && !exec_screenshooter_interactive(path)) {
return -1;
ret = -1;
goto destroy_request;
}
if (!interactive && !exec_screenshooter(path)) {
return -1;
ret = -1;
goto destroy_request;
}

sd_bus_message *reply = NULL;
Expand All @@ -144,6 +146,8 @@ static int method_screenshot(sd_bus_message *msg, void *data,

unref_reply:
sd_bus_message_unref(reply);
destroy_request:
xdpw_request_destroy(req);
return ret;
}

Expand Down

0 comments on commit 0776565

Please sign in to comment.