[cfe-commits] r112738 - in /cfe/trunk: lib/Checker/CastSizeChecker.cpp test/Analysis/misc-ps.m

Ted Kremenek kremenek at apple.com
Wed Sep 1 13:35:39 PDT 2010


Author: kremenek
Date: Wed Sep  1 15:35:38 2010
New Revision: 112738

URL: http://llvm.org/viewvc/llvm-project?rev=112738&view=rev
Log:
Don't assert in CastSizeChecker when the casted-to pointee is an incomplete type.  Fixes PR 8050.

Modified:
    cfe/trunk/lib/Checker/CastSizeChecker.cpp
    cfe/trunk/test/Analysis/misc-ps.m

Modified: cfe/trunk/lib/Checker/CastSizeChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/CastSizeChecker.cpp?rev=112738&r1=112737&r2=112738&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/CastSizeChecker.cpp (original)
+++ cfe/trunk/lib/Checker/CastSizeChecker.cpp Wed Sep  1 15:35:38 2010
@@ -44,6 +44,10 @@
 
   QualType ToPointeeTy = ToPTy->getPointeeType();
 
+  // Only perform the check if 'ToPointeeTy' is a complete type.
+  if (ToPointeeTy->isIncompleteType())
+    return;
+
   const GRState *state = C.getState();
   const MemRegion *R = state->getSVal(E).getAsRegion();
   if (R == 0)

Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=112738&r1=112737&r2=112738&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Wed Sep  1 15:35:38 2010
@@ -1056,3 +1056,15 @@
   *p = 0xDEADBEEF; // expected-warning{{null pointer}}
 }
 
+// PR 8050 - crash in CastSizeChecker when pointee is an incomplete type
+typedef long unsigned int __darwin_size_t;
+typedef __darwin_size_t size_t;
+void *malloc(size_t);
+
+struct PR8050;
+
+void pr8050(struct PR8050 **arg)
+{
+    *arg = malloc(1);
+}
+





More information about the cfe-commits mailing list