aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp')
-rw-r--r--lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp b/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
index 3e80d9cc42..f9a43fdc3a 100644
--- a/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
@@ -119,10 +119,21 @@ void MacOSKeychainAPIChecker::checkPostStmt(const CallExpr *CE,
if (idx != InvalidParamVal) {
SVal Param = State->getSVal(CE->getArg(idx));
if (const loc::MemRegionVal *X = dyn_cast<loc::MemRegionVal>(&Param)) {
- SymbolRef V = SM.Retrieve (State->getStore(), *X).getAsSymbol();
+ // Add the symbolic value, which represents the location of the allocated
+ // data, to the set.
+ SymbolRef V = SM.Retrieve(State->getStore(), *X).getAsSymbol();
if (!V)
return;
State = State->add<AllocatedData>(V);
+
+ // We only need to track the value if the function returned noErr(0), so
+ // bind the return value of the function to 0.
+ SValBuilder &Builder = C.getSValBuilder();
+ SVal ZeroVal = Builder.makeZeroVal(Builder.getContext().CharTy);
+ State = State->BindExpr(CE, ZeroVal);
+ assert(State);
+
+ // Proceed from the new state.
C.addTransition(State);
}
}