From: dongshengyuan <545258830@qq.com> Date: Tue, 30 Jun 2026 09:13:10 +0000 (+0800) Subject: resolvectl: fix JSON reply cleanup in varlink_dump_dns_configuration X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F42812%2Fhead;p=thirdparty%2Fsystemd.git resolvectl: fix JSON reply cleanup in varlink_dump_dns_configuration varlink_call_and_log() does not hand out a new reference for the reply object, so the caller should not unref it. The _cleanup_(sd_json_variant_unrefp) on reply was therefore wrong from the start. The original TAKE_PTR(reply) was working around this incorrect cleanup by preventing it from firing, but that left reply's refcount one too high after sd_json_variant_ref(v) incremented the parent's count. Fix by dropping _cleanup_(sd_json_variant_unrefp) from the reply variable declaration entirely, as suggested by Lennart Poettering. Signed-off-by: dongshengyuan --- diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c index af7ed436726..011162865b8 100644 --- a/src/resolve/resolvectl.c +++ b/src/resolve/resolvectl.c @@ -1114,7 +1114,7 @@ static int verb_tlsa(int argc, char *argv[], uintptr_t _data, void *userdata) { static int varlink_dump_dns_configuration(sd_json_variant **ret) { _cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL; - _cleanup_(sd_json_variant_unrefp) sd_json_variant *reply = NULL; + sd_json_variant *reply = NULL; sd_json_variant *v; int r; @@ -1133,7 +1133,6 @@ static int varlink_dump_dns_configuration(sd_json_variant **ret) { if (!sd_json_variant_is_array(v)) return log_error_errno(SYNTHETIC_ERRNO(ENODATA), "DumpDNSConfiguration() response missing 'configuration' key."); - TAKE_PTR(reply); *ret = sd_json_variant_ref(v); return 0; }