render: Fix memory leaks in rendering.