Changeset 033646


Ignore:
Timestamp:
Dec 26, 2025, 9:40:14 PM (4 days ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Candidate_v1.7.1, stable
Children:
c742bb1
Parents:
c8cb0d
git-author:
Frederik Heber <frederik.heber@…> (12/10/25 21:00:56)
git-committer:
Frederik Heber <frederik.heber@…> (12/26/25 21:40:14)
Message:

FIX: Insecure access in GLWorldScene on reparenting.

  • We dereferenced two nested pointers where the first access was checked but the second not. This is now done cleanly in the reparenting in GLWorldScene. ... except for the last getIndex() access. But at least in may only be already free'd memory and not NULL.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp

    rc8cb0d r033646  
    421421  }
    422422  {
    423     if ((_bond->getLeftAtom() != NULL) && (_bond->getLeftAtom()->getMoleculeRef() != NULL))
    424       BondNodeParentMaps[0].left.insert(
    425           std::make_pair(bondid, _bond->getLeftAtom()->getMoleculeRef()->getIndex()) );
    426     else
    427       BondNodeParentMaps[0].left.insert(
    428           std::make_pair(bondid, (ObservedValue_Index_t)NULL) );
    429     if ((_bond->getRightAtom() != NULL) && (_bond->getRightAtom()->getMoleculeRef() != NULL))
    430       BondNodeParentMaps[1].left.insert(
    431           std::make_pair(bondid, _bond->getRightAtom()->getMoleculeRef()->getIndex()) );
    432     else
    433       BondNodeParentMaps[1].left.insert(
    434           std::make_pair(bondid, (ObservedValue_Index_t)NULL) );
     423    {
     424      const QtObservedAtom::ptr leftAtom = _bond->getLeftAtom();
     425      if (leftAtom != NULL) {
     426        const QtObservedMolecule * const molRef = leftAtom->getMoleculeRef();
     427        if (molRef != NULL)
     428          BondNodeParentMaps[0].left.insert(
     429              std::make_pair(bondid, molRef->getIndex()) );
     430        else
     431          BondNodeParentMaps[0].left.insert(
     432              std::make_pair(bondid, (ObservedValue_Index_t)NULL) );
     433      } else {
     434        BondNodeParentMaps[0].left.insert(
     435            std::make_pair(bondid, (ObservedValue_Index_t)NULL) );
     436      }
     437    }
     438    {
     439      const QtObservedAtom::ptr rightAtom = _bond->getRightAtom();
     440      if (rightAtom != NULL) {
     441        const QtObservedMolecule * const molRef = rightAtom->getMoleculeRef();
     442        if (molRef != NULL)
     443          BondNodeParentMaps[1].left.insert(
     444              std::make_pair(bondid, molRef->getIndex()) );
     445        else
     446          BondNodeParentMaps[1].left.insert(
     447              std::make_pair(bondid, (ObservedValue_Index_t)NULL) );
     448      } else {
     449        BondNodeParentMaps[1].left.insert(
     450            std::make_pair(bondid, (ObservedValue_Index_t)NULL) );
     451      }
     452    }
    435453  }
    436454
     
    744762  // change parent entry
    745763  AtomNodeParentMap.left.erase(parentiter);
    746   if (walker->getMoleculeRef() != NULL)
    747     AtomNodeParentMap.left.insert( std::make_pair(walkerid, walker->getMoleculeRef()->getIndex()) );
     764  const QtObservedMolecule * molRef = walker->getMoleculeRef();
     765  if (molRef != NULL)
     766    AtomNodeParentMap.left.insert( std::make_pair(walkerid, molRef->getIndex()) );
    748767  else
    749768    AtomNodeParentMap.left.insert( std::make_pair(walkerid, (ObservedValue_Index_t)NULL) );
     
    841860  // change parent entry
    842861  BondNodeParentMaps[dim].left.erase(bondid);
    843   if ((_atom != NULL) && (_atom->getMoleculeRef() != NULL))
    844     BondNodeParentMaps[dim].left.insert( std::make_pair( bondid, _atom->getMoleculeRef()->getIndex()));
    845   else
     862  if (_atom != NULL) {
     863    const QtObservedMolecule * const molRef = _atom->getMoleculeRef();
     864    if (molRef != NULL)
     865      BondNodeParentMaps[dim].left.insert( std::make_pair( bondid, molRef->getIndex()));
     866    else
     867      BondNodeParentMaps[dim].left.insert( std::make_pair( bondid, (ObservedValue_Index_t)NULL) );
     868  } else {
    846869    BondNodeParentMaps[dim].left.insert( std::make_pair( bondid, (ObservedValue_Index_t)NULL) );
     870  }
    847871  parentiter = BondNodeParentMaps[dim].left.find(bondid);
    848872  LOG(3, "INFO: GLWorldScene::reparentBond() - Reparented bond "
Note: See TracChangeset for help on using the changeset viewer.