diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2019-08-12 23:31:13 -0700 |
|---|---|---|
| committer | Pietro Albini <pietro@pietroalbini.org> | 2019-08-21 08:51:01 +0200 |
| commit | 10d652107b51d2a9d6b3f0d128a74fdee1ff07e8 (patch) | |
| tree | 70d25be6022b8e79d78ebaa7c44ae196ef0fa050 /src/libsyntax | |
| parent | 539db8154ecd53b549e74f2a9f297476feb9b1d0 (diff) | |
Do not ICE when synthesizing spans falling inside unicode chars
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/source_map.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libsyntax/source_map.rs b/src/libsyntax/source_map.rs index 4e29c77c89e..3c58cfbbb2b 100644 --- a/src/libsyntax/source_map.rs +++ b/src/libsyntax/source_map.rs @@ -554,8 +554,14 @@ impl SourceMap { } if let Some(ref src) = local_begin.sf.src { + if !src.is_char_boundary(start_index) || !src.is_char_boundary(end_index) { + return Err(SpanSnippetError::IllFormedSpan(sp)); + } return Ok(extract_source(src, start_index, end_index)); } else if let Some(src) = local_begin.sf.external_src.borrow().get_source() { + if !src.is_char_boundary(start_index) || !src.is_char_boundary(end_index) { + return Err(SpanSnippetError::IllFormedSpan(sp)); + } return Ok(extract_source(src, start_index, end_index)); } else { return Err(SpanSnippetError::SourceNotAvailable { |
