diff options
| author | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-11-24 05:16:01 +0000 |
|---|---|---|
| committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-11-24 05:16:01 +0000 |
| commit | f556cd6cb9f6a34e1b1679aadd7b07fd725f10c5 (patch) | |
| tree | ab96c6282166abb0a229ce540fd02e086775286d /clang | |
| parent | 87da2b5dce0a7609df081297c7c13b952760805a (diff) | |
| download | bcm5719-llvm-f556cd6cb9f6a34e1b1679aadd7b07fd725f10c5.tar.gz bcm5719-llvm-f556cd6cb9f6a34e1b1679aadd7b07fd725f10c5.zip | |
Strings are NULL terminated. So the region size should plus one.
llvm-svn: 59943
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Analysis/RegionStore.cpp | 2 | ||||
| -rw-r--r-- | clang/test/Analysis/outofbound.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp index 73b25955c14..99c225f5e83 100644 --- a/clang/lib/Analysis/RegionStore.cpp +++ b/clang/lib/Analysis/RegionStore.cpp @@ -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)) { diff --git a/clang/test/Analysis/outofbound.c b/clang/test/Analysis/outofbound.c index 17608ff1687..6e6e8f033b5 100644 --- a/clang/test/Analysis/outofbound.c +++ b/clang/test/Analysis/outofbound.c @@ -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.}} } |

