Coverity: Dereference after null check

This commit is contained in:
wmayer
2020-07-19 15:44:52 +02:00
parent 433ec2d6e4
commit 421f6c52cb
11 changed files with 59 additions and 38 deletions

View File

@@ -1463,31 +1463,36 @@ std::string ObjectIdentifier::String::toString(bool toPython) const
void ObjectIdentifier::String::checkImport(const App::DocumentObject *owner,
const App::DocumentObject *obj, String *objName)
{
if(owner && owner->getDocument() &&
str.size() &&
ExpressionParser::ExpressionImporter::reader())
{
if(owner && owner->getDocument() && str.size() &&
ExpressionParser::ExpressionImporter::reader()) {
auto reader = ExpressionParser::ExpressionImporter::reader();
if(obj || objName) {
if (obj || objName) {
bool restoreLabel = false;
str = PropertyLinkBase::importSubName(*reader,str.c_str(),restoreLabel);
if(restoreLabel) {
if(!obj) {
if (restoreLabel) {
if (!obj) {
std::bitset<32> flags;
obj = getDocumentObject(owner->getDocument(),*objName,flags);
if(!obj)
if (!obj) {
FC_ERR("Cannot find object " << objName->toString());
}
}
if (obj) {
PropertyLinkBase::restoreLabelReference(obj,str);
}
PropertyLinkBase::restoreLabelReference(obj,str);
}
} else if (str.back()!='@')
}
else if (str.back()!='@') {
str = reader->getName(str.c_str());
else{
}
else {
str.resize(str.size()-1);
auto mapped = reader->getName(str.c_str());
auto obj = owner->getDocument()->getObject(mapped);
if(!obj)
if (!obj) {
FC_ERR("Cannot find object " << str);
}
else {
isString = true;
forceIdentifier = false;