[PATCH] D83660: [analyzer] Fix a crash for dereferencing an empty llvm::Optional variable in SMTConstraintManager.h.

Ella Ma via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 13 00:52:54 PDT 2020


OikawaKirie created this revision.
OikawaKirie added reviewers: NoQ, dcoughlin.
OikawaKirie added a project: clang.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.

The first crash reported in the bug report 44338 <https://bugs.llvm.org/show_bug.cgi?id=44338>.

> Condition `!isSat.hasValue() || isNotSat.getValue()` here should be `!isNotSat.hasValue() || isNotSat.getValue()`.
>  `getValue` here crashed when we used the static analyzer to analyze postgresql-12.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83660

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
===================================================================
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
@@ -147,7 +147,7 @@
       Solver->addConstraint(NotExp);
 
       Optional<bool> isNotSat = Solver->check();
-      if (!isSat.hasValue() || isNotSat.getValue())
+      if (!isNotSat.hasValue() || isNotSat.getValue())
         return nullptr;
 
       // This is the only solution, store it


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83660.277339.patch
Type: text/x-patch
Size: 606 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200713/745e0d8c/attachment.bin>


More information about the cfe-commits mailing list