diff options
author | Devin Coughlin <dcoughlin@apple.com> | 2016-12-16 18:41:40 +0000 |
---|---|---|
committer | Devin Coughlin <dcoughlin@apple.com> | 2016-12-16 18:41:40 +0000 |
commit | e3b75ded98fefbd9b52d897b25bb619cfa4df699 (patch) | |
tree | 13e7e12e78a5d9c54d8907e56e18726fc1b2805a /clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp | |
parent | 8980ba643e3ec8d00d7cdf75a3a298fa1fd4fee2 (diff) | |
download | bcm5719-llvm-e3b75ded98fefbd9b52d897b25bb619cfa4df699.tar.gz bcm5719-llvm-e3b75ded98fefbd9b52d897b25bb619cfa4df699.zip |
[analyzer] Fix crash in MallocChecker.
Fix a crash in the MallocChecker when the extent size for the argument
to new[] is not known.
A patch by Abramo Bagnara and Dániel Krupp!
https://reviews.llvm.org/D27849
Differential Revision: https://reviews.llvm.org/D27849
llvm-svn: 289970
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 07c607212d7..f7c4ea10c43 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -1026,8 +1026,7 @@ ProgramStateRef MallocChecker::addExtentSize(CheckerContext &C, ASTContext &AstContext = C.getASTContext(); CharUnits TypeSize = AstContext.getTypeSizeInChars(ElementType); - if (Optional<DefinedOrUnknownSVal> DefinedSize = - ElementCount.getAs<DefinedOrUnknownSVal>()) { + if (ElementCount.getAs<NonLoc>()) { DefinedOrUnknownSVal Extent = Region->getExtent(svalBuilder); // size in Bytes = ElementCount*TypeSize SVal SizeInBytes = svalBuilder.evalBinOpNN( |