]> granicus.if.org Git - clang/commitdiff
[Tooling] fix UB when interpolating compile commands with an empty index
authorSam McCall <sam.mccall@gmail.com>
Tue, 10 Apr 2018 10:36:46 +0000 (10:36 +0000)
committerSam McCall <sam.mccall@gmail.com>
Tue, 10 Apr 2018 10:36:46 +0000 (10:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329685 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Tooling/InterpolatingCompilationDatabase.cpp

index cc292348915a5612cfce78261bd6c12d46a34f00..cf29744f3075deb8b06da7b38f9c76b4f510577a 100644 (file)
@@ -373,8 +373,8 @@ private:
   ArrayRef<SubstringAndIndex>
   indexLookup(StringRef Key, const std::vector<SubstringAndIndex> &Idx) const {
     // Use pointers as iteratiors to ease conversion of result to ArrayRef.
-    auto Range =
-        std::equal_range(&Idx[0], &Idx[Idx.size()], Key, Less<Prefix>());
+    auto Range = std::equal_range(Idx.data(), Idx.data() + Idx.size(), Key,
+                                  Less<Prefix>());
     return {Range.first, Range.second};
   }