eaeltsin wrote:

Ok, the problem is in clang/lib/Frontend/TextDiagnostic.cpp:1352:
```
  std::unique_ptr<SmallVector<StyleRange>[]> SourceStyles =
      highlightLines(BufStart, Lines.first, Lines.second, PP, LangOpts,
                     DiagOpts->ShowColors, FID, SM);
```

Looks like passing `BufStart` creates a StringRef that doesn't cover all the 
data.

Replacing this to 
```
  std::unique_ptr<SmallVector<StyleRange>[]> SourceStyles =
      highlightLines(StringRef(BufStart, BufEnd - BufStart), Lines.first, 
Lines.second, PP, LangOpts,
                     DiagOpts->ShowColors, FID, SM);
```
makes the crash go away.

I don't know this code so cannot comment more on what actually happens. The 
only thing to add is that the crash occurred because offset returned in line 
1154 was way out of bounds of buffer created at line 1148.

Please fix.


https://github.com/llvm/llvm-project/pull/66514
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to