diff options
| author | Christopher Dannemiller <cdannemiller@nvidia.com> | 2019-05-21 14:56:56 -0700 |
|---|---|---|
| committer | jsmall-nvidia <jsmall@nvidia.com> | 2019-05-21 17:56:56 -0400 |
| commit | 7a24a4285c342ca5dea9a3b3fe176c4348aa9a51 (patch) | |
| tree | b85585fc2ce150006b0b7242e00ac7ef59dfc27e /source/slang/source-loc.cpp | |
| parent | c2b4c5838431e12abb6f233c459d3d6a717aad18 (diff) | |
Fix a buffer overrun that can occur when the last byte of the file is '\r' or '\n' and the by adjacent to the last character in the file in memory is '\r' or '\n'. (#969)
Diffstat (limited to 'source/slang/source-loc.cpp')
| -rw-r--r-- | source/slang/source-loc.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/source/slang/source-loc.cpp b/source/slang/source-loc.cpp index b67426053..c66fdedb5 100644 --- a/source/slang/source-loc.cpp +++ b/source/slang/source-loc.cpp @@ -234,9 +234,13 @@ const List<uint32_t>& SourceFile::getLineBreakOffsets() // where a multi-byte sequence might encode // the line break. - int d = *cursor; - if ((c^d) == ('\r' ^ '\n')) - cursor++; + // Check to make sure that the EOF hasn't been reached. + if (cursor != end) + { + int d = *cursor; + if ((c ^ d) == ('\r' ^ '\n')) + cursor++; + } m_lineBreakOffsets.add(uint32_t(cursor - begin)); break; |
