From 0e638ffef96a5a7bf9f2642dedff115c30d0a5a5 Mon Sep 17 00:00:00 2001 From: icedream Date: Wed, 7 May 2014 22:04:33 +0200 Subject: [PATCH] Some null-case handling. --- src/libnpsharp/Authentication/AuthenticationHelper.cs | 6 ++++++ 1 file changed, 6 insertions(+) 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;