math: Fix memory leak