]> granicus.if.org Git - clang/commitdiff
Strings are NULL terminated. So the region size should plus one.
authorZhongxing Xu <xuzhongxing@gmail.com>
Mon, 24 Nov 2008 05:16:01 +0000 (05:16 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Mon, 24 Nov 2008 05:16:01 +0000 (05:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59943 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/RegionStore.cpp
test/Analysis/outofbound.c

index 73b25955c14d34ef0859713d5bf05d5656cd7e0b..99c225f5e83d31a7dcfcb2f848a8f4c3ebde74a2 100644 (file)
@@ -275,7 +275,7 @@ SVal RegionStoreManager::getSizeInElements(const GRState* St,
     const StringLiteral* Str = SR->getStringLiteral();
     // We intentionally made the size value signed because it participates in 
     // operations with signed indices.
-    return NonLoc::MakeVal(getBasicVals(), Str->getByteLength(), false);
+    return NonLoc::MakeVal(getBasicVals(), Str->getByteLength() + 1, false);
   }
 
   if (const AnonTypedRegion* ATR = dyn_cast<AnonTypedRegion>(R)) {
index 17608ff1687294d2232f0a05394b83d82b243f70..6e6e8f033b5357062fdece5b4411d7411571d173 100644 (file)
@@ -2,5 +2,5 @@
 
 char f1() {
   char* s = "abcd";
-  return s[4]; // expected-warning{{Load or store into an out-of-bound memory position.}}
+  return s[5]; // expected-warning{{Load or store into an out-of-bound memory position.}}
 }