apigenerator: fix leaks in bridged calls