[PATCH] Fix memory corruption in CStringChecker

Pavel Labath labath at google.com
Tue Jun 11 01:30:27 PDT 2013


Hi klimek,

"register" functions for the checker were caching the checker objects in a
static variable. This caused problems when the function is called with a
different CheckerManager.

http://llvm-reviews.chandlerc.com/D955

Files:
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp

Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -2018,10 +2018,7 @@
 
 #define REGISTER_CHECKER(name) \
 void ento::register##name(CheckerManager &mgr) {\
-  static CStringChecker *TheChecker = 0; \
-  if (TheChecker == 0) \
-    TheChecker = mgr.registerChecker<CStringChecker>(); \
-  TheChecker->Filter.Check##name = true; \
+  mgr.registerChecker<CStringChecker>()->Filter.Check##name = true; \
 }
 
 REGISTER_CHECKER(CStringNullArg)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D955.1.patch
Type: text/x-patch
Size: 617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130611/1fde90be/attachment.bin>


More information about the cfe-commits mailing list