diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-08-03 21:41:46 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-08-03 21:41:46 +0000 |
commit | 968f0a6fe860b7df42d5ea1ab87a55c757507c1c (patch) | |
tree | 65925ca75c4d8dd9c28c59986e5efc8262cfe99b | |
parent | e3d25abca3f0e0c92417734d6f548c5085ee1241 (diff) |
Handle disgusting corner case where a byte is loaded from the address of a function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78000 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/RegionStore.cpp | 4 | ||||
-rw-r--r-- | test/Analysis/misc-ps.m | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp index 543783d924..c47aaa20e0 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -882,6 +882,9 @@ RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) { MR = MRMgr.getElementRegion(T, idx, MR, Ctx); } + if (isa<CodeTextRegion>(MR)) + return SValuator::CastResult(state, UnknownVal()); + // FIXME: Perhaps this method should just take a 'const MemRegion*' argument // instead of 'Loc', and have the other Loc cases handled at a higher level. const TypedRegion *R = cast<TypedRegion>(MR); @@ -1000,7 +1003,6 @@ SVal RegionStoreManager::RetrieveElement(const GRState* state, if (R->getIndex().isZeroConstant()) { if (const TypedRegion *superTR = dyn_cast<TypedRegion>(superR)) { ASTContext &Ctx = getContext(); - if (IsAnyPointerOrIntptr(superTR->getValueType(Ctx), Ctx)) { QualType valTy = R->getValueType(Ctx); if (IsAnyPointerOrIntptr(valTy, Ctx)) { diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index c4fa7a8a1d..5cfcd714cd 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -499,3 +499,12 @@ void test_cast_const_voidptr() { char *p = &x[1]; const void* q = p; } + +// Reduced from a crash when analyzing Wine. This test handles loads from +// function addresses. +typedef long (*FARPROC)(); +FARPROC test_load_func(FARPROC origfun) { + if (!*(unsigned char*) origfun) + return origfun; + return 0; +} |