memory leak in path operation
fix leaks in cursor functions