From: Paul Chaignon Date: Wed, 23 Aug 2017 05:25:30 +0000 (+0200) Subject: Fix segfault on incomplete types X-Git-Tag: submit/tizen_4.0/20171018.110122~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d32a61b076ded297afab5bbbb7fd6178ee274e71;p=platform%2Fupstream%2Fbcc.git Fix segfault on incomplete types The bcc rewriter segfaults when it encounters an incomplete type (missing declaration or declaration after use) in a map declaration. This commit fixes it by first checking the type and returning an error if it is incomplete. --- diff --git a/src/cc/frontends/clang/b_frontend_action.cc b/src/cc/frontends/clang/b_frontend_action.cc index 87ed228b..c6218ff4 100644 --- a/src/cc/frontends/clang/b_frontend_action.cc +++ b/src/cc/frontends/clang/b_frontend_action.cc @@ -621,6 +621,11 @@ bool BTypeVisitor::VisitVarDecl(VarDecl *Decl) { unsigned i = 0; for (auto F : RD->fields()) { + if (F->getType().getTypePtr()->isIncompleteType()) { + error(F->getLocStart(), "unknown type"); + return false; + } + size_t sz = C.getTypeSize(F->getType()) >> 3; if (F->getName() == "key") { if (sz == 0) {