svn commit: r279289 - in stable: 10/contrib/llvm/tools/clang/lib/AST 9/contrib/llvm/tools/clang/lib/AST

Dimitry Andric dim at FreeBSD.org
Wed Feb 25 17:27:03 UTC 2015


Author: dim
Date: Wed Feb 25 17:27:02 2015
New Revision: 279289
URL: https://svnweb.freebsd.org/changeset/base/279289

Log:
  Pull in r199571 from upstream clang trunk (by Ted Kremenek):
  
    Harden InitListExpr::isStringLiteralInit() against getInit()
    returning null.
  
    This led to a crash on invalid code (sorry, no good test case).
  
    Fixes <rdar://problem/15831804>.
  
  This fixes an assertion when compiling certain incorrect code, as
  reported upstream in http://llvm.org/PR22684 .
  
  Direct commit to stable/10 and stable/9, since head has clang 3.5.1,
  which already includes this change.
  
  Reported by:	hbowden at securelabsllc.com

Modified:
  stable/9/contrib/llvm/tools/clang/lib/AST/Expr.cpp

Changes in other areas also in this revision:
Modified:
  stable/10/contrib/llvm/tools/clang/lib/AST/Expr.cpp

Modified: stable/9/contrib/llvm/tools/clang/lib/AST/Expr.cpp
==============================================================================
--- stable/9/contrib/llvm/tools/clang/lib/AST/Expr.cpp	Wed Feb 25 17:06:27 2015	(r279288)
+++ stable/9/contrib/llvm/tools/clang/lib/AST/Expr.cpp	Wed Feb 25 17:27:02 2015	(r279289)
@@ -1892,7 +1892,11 @@ bool InitListExpr::isStringLiteralInit()
   const ArrayType *AT = getType()->getAsArrayTypeUnsafe();
   if (!AT || !AT->getElementType()->isIntegerType())
     return false;
-  const Expr *Init = getInit(0)->IgnoreParens();
+  // It is possible for getInit() to return null.
+  const Expr *Init = getInit(0);
+  if (!Init)
+    return false;
+  Init = Init->IgnoreParens();
   return isa<StringLiteral>(Init) || isa<ObjCEncodeExpr>(Init);
 }
 


More information about the svn-src-stable-9 mailing list