[PATCH] D58178: isRawStringLiteral doesn't check all erroneous cases
Goran Mitrovic via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 13 07:17:38 PST 2019
gmit created this revision.
gmit added a reviewer: alexfh.
gmit added a project: clang-tools-extra.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
isRawStringLiteral will read from memory randomly if double quote is not found.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D58178
Files:
RawStringLiteralCheck.cpp
Index: RawStringLiteralCheck.cpp
===================================================================
--- RawStringLiteralCheck.cpp
+++ RawStringLiteralCheck.cpp
@@ -38,7 +38,8 @@
// Already a raw string literal if R comes before ".
const size_t QuotePos = Text.find('"');
assert(QuotePos != StringRef::npos);
- return (QuotePos > 0) && (Text[QuotePos - 1] == 'R');
+ return (QuotePos != StringRef::npos) && (QuotePos > 0) &&
+ (Text[QuotePos - 1] == 'R');
}
bool containsEscapedCharacters(const MatchFinder::MatchResult &Result,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58178.186650.patch
Type: text/x-patch
Size: 552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190213/ea5eb7b9/attachment.bin>
More information about the cfe-commits
mailing list