codegen: Fix memory leak introduced by fe9beb82b6809