From: Nick Lewycky Date: Sat, 6 Sep 2014 01:16:42 +0000 (+0000) Subject: Check whether the iterator p == the end iterator before trying to dereference it... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=05ad06754c0508ce9c661e84fb109037810eae20;p=oota-llvm.git Check whether the iterator p == the end iterator before trying to dereference it. This is a speculative fix for a failure found on the valgrind buildbot triggered by a clang test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217295 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp index 097986d3e7c..659914a85f5 100644 --- a/lib/Support/APFloat.cpp +++ b/lib/Support/APFloat.cpp @@ -212,15 +212,15 @@ skipLeadingZeroesAndAnyDot(StringRef::iterator begin, StringRef::iterator end, { StringRef::iterator p = begin; *dot = end; - while (*p == '0' && p != end) + while (p != end && *p == '0') p++; - if (*p == '.') { + if (p != end && *p == '.') { *dot = p++; assert(end - begin != 1 && "Significand has no digits"); - while (*p == '0' && p != end) + while (p != end && *p == '0') p++; }