diff options
author | dim <dim@FreeBSD.org> | 2015-02-25 17:27:02 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-02-25 17:27:02 +0000 |
commit | 3ebe79edba7c5e44da137fd957e61f314da5ded7 (patch) | |
tree | 744a32fb219b47857ad394fda045e2cad52dc8b8 /contrib/llvm/tools/clang/lib | |
parent | ab185f6ca702fafceab87e544bd81c1fc3b2e3ff (diff) | |
download | FreeBSD-src-3ebe79edba7c5e44da137fd957e61f314da5ded7.zip FreeBSD-src-3ebe79edba7c5e44da137fd957e61f314da5ded7.tar.gz |
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@securelabsllc.com
Diffstat (limited to 'contrib/llvm/tools/clang/lib')
-rw-r--r-- | contrib/llvm/tools/clang/lib/AST/Expr.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
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<StringLiteral>(Init) || isa<ObjCEncodeExpr>(Init); } |