Coverity: Close directory handle along error paths.