From 3ebe79edba7c5e44da137fd957e61f314da5ded7 Mon Sep 17 00:00:00 2001 From: dim Date: Wed, 25 Feb 2015 17:27:02 +0000 Subject: 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 . 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@securelabsllc.com --- contrib/llvm/tools/clang/lib/AST/Expr.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'contrib/llvm/tools/clang/lib/AST/Expr.cpp') diff --git a/contrib/llvm/tools/clang/lib/AST/Expr.cpp b/contrib/llvm/tools/clang/lib/AST/Expr.cpp index 9055ddac..a262522 100644 --- a/contrib/llvm/tools/clang/lib/AST/Expr.cpp +++ b/contrib/llvm/tools/clang/lib/AST/Expr.cpp @@ -1892,7 +1892,11 @@ bool InitListExpr::isStringLiteralInit() const { 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(Init) || isa(Init); } -- cgit v1.1