From 0776565326ad468b422b49af1c98ee4d434c23ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Sat, 18 May 2024 15:33:22 +0200 Subject: [PATCH] screenshot: clean up xdpw request 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. --- src/screenshot/screenshot.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/screenshot/screenshot.c b/src/screenshot/screenshot.c index 0cf61f49..3b47d341 100644 --- a/src/screenshot/screenshot.c +++ b/src/screenshot/screenshot.c @@ -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; @@ -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; }