Fixed permission-related memory leak