]> granicus.if.org Git - clang/commit
Lex: Fix an invalid access into a SmallString
authorDavid Majnemer <david.majnemer@gmail.com>
Sat, 25 Oct 2014 11:40:40 +0000 (11:40 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sat, 25 Oct 2014 11:40:40 +0000 (11:40 +0000)
commitc58c5c9d0c9a4577863961f6122bd2c03e342d44
tree8a98ccb293a9e6f842c8c93ea02f611f776e5df5
parent26951a4cd381b162290226ca72dc5b6c33efefaa
Lex: Fix an invalid access into a SmallString

We would crash because we used operator[] to access past the end of a
SmallString.  This occured because our token had length zero.

Instead, form the pointer using .data() and arithmetic.  This is safe
because this forms a one-past-the-end pointer and it is only used to
compare with another one-past-the-end pointer.

This fixes PR21379.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220614 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Lex/MacroArgs.cpp
lib/Lex/TokenLexer.cpp
test/Preprocessor/macro_paste_bad.c