diff --git a/src/libnpsharp/Authentication/AuthenticationHelper.cs b/src/libnpsharp/Authentication/AuthenticationHelper.cs index 95c0fb7..a7f3084 100644 --- a/src/libnpsharp/Authentication/AuthenticationHelper.cs +++ b/src/libnpsharp/Authentication/AuthenticationHelper.cs @@ -80,10 +80,16 @@ namespace NPSharp.Authentication var rx = new Regex("^(?ok|fail)#(?.+)#(?[0-9]+)#(?.+)#(?.+)#(?.+)$"); var resp = (HttpWebResponse)req.GetResponse (); using (var respStream = resp.GetResponseStream()) { + if (respStream == null) + throw new Exception(@"No answer from server"); using (var respReader = new StreamReader(respStream)) { while (!respReader.EndOfStream) { var line = respReader.ReadLine (); + // No answer? + if (string.IsNullOrEmpty(line)) + continue; + // DW response line found? if (!rx.IsMatch (line)) continue;