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 <dongshengyuan@uniontech.com>
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;
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;
}