aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/ExplodedGraph.cpp
diff options
context:
space:
mode:
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() {