Fix leaks

Fix some leaks in cockpit-agent. Misunderstood the ownership of the return result of ```json_builder_get_root()```.