fix memory leak with cgpath