[cfe-dev] [StaticAnalyzer] Potential bug in MemRegion.cpp?
Aditya Kumar
hiraditya at codeaurora.org
Thu Sep 19 08:15:26 PDT 2013
When the following function is called by (RegionOffset
MemRegion::getAsOffset() const:1257), and the first parameter (Child) is a
NULL pointer I get a segmentation fault.
@file: MemRegion.cpp
01164 static bool isImmediateBase(const CXXRecordDecl *Child,
01165 const CXXRecordDecl *Base) {
01166 // Note that we do NOT canonicalize the base class here, because
01167 // ASTRecordLayout doesn't either. If that leads us down the wrong
path,
01168 // so be it; at least we won't crash.
01169 for (CXXRecordDecl::base_class_const_iterator I =
Child->bases_begin(),
01170 E =
Child->bases_end();
01171 I != E; ++I) {
01172 if (I->getType()->getAsCXXRecordDecl() == Base)
01173 return true;
01174 }
01175
01176 return false;
01177 }
For now I just return `false' when `Child' pointer is NULL. Is this fix okay
or there is something else required to be done?
Thanks,
-Aditya
More information about the cfe-dev
mailing list