[edit] Don't hit an assert when trying to delete a trailing space at EOF
The buffer is guaranteed to be zero-terminated so we can just circumvent the check. Found by afl-fuzz. llvm-svn: 233496
This commit is contained in:
parent
d15c2805ab
commit
851f310cec
|
@ -295,9 +295,11 @@ static void adjustRemoval(const SourceManager &SM, const LangOptions &LangOpts,
|
|||
}
|
||||
|
||||
if (buffer[end] == ' ') {
|
||||
assert((end + 1 != buffer.size() || buffer.data()[end + 1] == 0) &&
|
||||
"buffer not zero-terminated!");
|
||||
if (canRemoveWhitespace(/*left=*/buffer[begin-1],
|
||||
/*beforeWSpace=*/buffer[end-1],
|
||||
/*right=*/buffer[end+1],
|
||||
/*right=*/buffer.data()[end + 1], // zero-terminated
|
||||
LangOpts))
|
||||
++len;
|
||||
return;
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// RUN: not %clang_cc1 %s -fsyntax-only -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
|
||||
// vim: set binary noeol:
|
||||
|
||||
// This file intentionally ends without a \n on the last line. Make sure your
|
||||
// editor doesn't add one. The trailing space is also intentional.
|
||||
|
||||
// CHECK: :9:8: warning: duplicate 'extern' declaration specifier
|
||||
// CHECK: fix-it:"{{.*}}":{9:8-9:15}:""
|
||||
extern extern
|
Loading…
Reference in New Issue