diff --git a/lib/Edit/EditedSource.cpp b/lib/Edit/EditedSource.cpp index 6cf6335da1..1c66cb8277 100644 --- a/lib/Edit/EditedSource.cpp +++ b/lib/Edit/EditedSource.cpp @@ -280,6 +280,12 @@ static void adjustRemoval(const SourceManager &SM, const LangOptions &LangOpts, unsigned begin = offs.getOffset(); unsigned end = begin + len; + // Do not try to extend the removal if we're at the end of the buffer already. + if (end == buffer.size()) + return; + + assert(begin < buffer.size() && end < buffer.size() && "Invalid range!"); + // FIXME: Remove newline. if (begin == 0) {