From af677c1dc8911802b9928d954a8ca8a1bb0a8329 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 9 Aug 2010 13:05:06 +0000 Subject: [PATCH] Avoid crash when using snippet parser on empty input. Fixes NullReferenceException in ICSharpCode.NRefactory.Parser.CSharp.Parser.ParseBlock. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6394 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs index 176d5546e7..e9b4542388 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs @@ -94,7 +94,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp if (expr.StartLocation.IsEmpty) expr.StartLocation = startLocation; if (expr.EndLocation.IsEmpty) - expr.EndLocation = t.EndLocation; + expr.EndLocation = (t ?? la).EndLocation; expr.AcceptVisitor(new SetParentVisitor(), null); } Expect(Tokens.EOF); @@ -120,7 +120,8 @@ namespace ICSharpCode.NRefactory.Parser.CSharp } BlockEnd(); - blockStmt.EndLocation = t.EndLocation; + // if lexer didn't return any tokens, use position of the EOF token in "la" + blockStmt.EndLocation = (t ?? la).EndLocation; Expect(Tokens.EOF); blockStmt.AcceptVisitor(new SetParentVisitor(), null); return blockStmt;