aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/ExplodedGraph.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-04-20 23:54:24 +0000
committerTed Kremenek <kremenek@apple.com>2008-04-20 23:54:24 +0000
commit7b989570f0fe262b6bdbad412577450c81304936 (patch)
tree1e36d628dd3d216029dca12069e9c132d0840794 /lib/Analysis/ExplodedGraph.cpp
parent1a1d92ac5e1354634af08c62a1d72e263d13be0c (diff)
Fix improper dereference of end() iterator. Patch by Argiris Kirtzidis!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50012 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ExplodedGraph.cpp')
-rw-r--r--lib/Analysis/ExplodedGraph.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Analysis/ExplodedGraph.cpp b/lib/Analysis/ExplodedGraph.cpp
index 3788551be0..c184d1ec42 100644
--- a/lib/Analysis/ExplodedGraph.cpp
+++ b/lib/Analysis/ExplodedGraph.cpp
@@ -80,8 +80,11 @@ ExplodedNodeImpl** ExplodedNodeImpl::NodeGroup::end() const {
if (getKind() == Size1)
return (ExplodedNodeImpl**) (getPtr() ? &P+1 : NULL);
- else
- return const_cast<ExplodedNodeImpl**>(&*(getVector(getPtr()).end()));
+ else {
+ // Dereferencing end() is undefined behaviour. The vector is not empty, so
+ // we can dereference the last elem (end()-1) and then add 1 to the result.
+ return const_cast<ExplodedNodeImpl**>(&*(getVector(getPtr()).end()-1)) + 1;
+ }
}
ExplodedNodeImpl::NodeGroup::~NodeGroup() {