Skip to content

[L1TopoCoreSim] Avoid potential nullptr dereference in messages

Avoid dereferencing nullptr. Found with clang-tidy:

warning: Called C++ object pointer is null [clang-analyzer-core.CallAndMessage]

in all cases here the pattern was:

void func(TypeA* ptrA) {
  TypeB* ptrB = dynamic_cast<TypeB*>(ptrA);
  if (!ptrB) {
    MSG( ptrA->foo() );
  }
}

where it was never checked if ptrA isn't nullptr.

Merge request reports