Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorJeffrey Stedfast <jestedfa@microsoft.com>2019-07-03 20:08:02 +0300
committerJeffrey Stedfast <jestedfa@microsoft.com>2019-07-03 20:31:06 +0300
commit8e84ee7731e1ff8ec7cf5e21356451a19e34f913 (patch)
treec6e2031bfba588afd1d84de6d1d7722e5eb2a1f6 /main
parent9cbe4d88dcf23eceb17d2a929fb1628d505a749a (diff)
[Debugger] Protect against NRE's in the CSharpBreakpointSpanResolver
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/935126/
Diffstat (limited to 'main')
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Debugger/CSharpBreakpointSpanResolver.cs7
1 files changed, 4 insertions, 3 deletions
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Debugger/CSharpBreakpointSpanResolver.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Debugger/CSharpBreakpointSpanResolver.cs
index e3d57dcec6..be9699573f 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Debugger/CSharpBreakpointSpanResolver.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Debugger/CSharpBreakpointSpanResolver.cs
@@ -47,11 +47,12 @@ namespace MonoDevelop.CSharp.Debugger
public async Task<Span> GetBreakpointSpanAsync (ITextBuffer buffer, int position, CancellationToken cancellationToken)
{
- var document = buffer.AsTextContainer ().GetOpenDocumentInCurrentContext ();
- var tree = await document.GetSyntaxTreeAsync (cancellationToken);
+ var document = buffer.AsTextContainer ()?.GetOpenDocumentInCurrentContext ();
+ var tree = document != null ? await document.GetSyntaxTreeAsync (cancellationToken) : null;
- if (BreakpointSpans.TryGetBreakpointSpan (tree, Math.Max (0, Math.Min (position, tree.Length - 1)), cancellationToken, out var span))
+ if (tree != null && BreakpointSpans.TryGetBreakpointSpan (tree, Math.Max (0, Math.Min (position, tree.Length - 1)), cancellationToken, out var span))
return new Span (span.Start, span.Length);
+
return buffer.CurrentSnapshot.GetLineFromPosition (Math.Max (0, Math.Min (position, buffer.CurrentSnapshot.Length - 1))).Extent.Span;
}
}