fix leak of 'dir'.