Skip to content

Commit a95435d

Browse files
committed
Fix null argument when expecting valid pointer in MatGetType()
[ci skip]
1 parent a2917c8 commit a95435d

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

plugin/mpi/PETSc-code.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,11 +1063,13 @@ namespace PETSc {
10631063
}
10641064
if (!isType) {
10651065
Mat backup = ptA->_petsc;
1066-
MatGetType(ptA->_petsc, &type);
1067-
PetscStrcmp(type, MATNEST, &isType);
1068-
if(isType) {
1069-
delete [] reinterpret_cast<HPDDM::Subdomain<PetscScalar>**>(ptA->_exchange);
1070-
ptA->_exchange = nullptr;
1066+
if (ptA->_petsc) {
1067+
MatGetType(ptA->_petsc, &type);
1068+
PetscStrcmp(type, MATNEST, &isType);
1069+
if (isType) {
1070+
delete [] reinterpret_cast<HPDDM::Subdomain<PetscScalar>**>(ptA->_exchange);
1071+
ptA->_exchange = nullptr;
1072+
}
10711073
}
10721074
ptA->_petsc = nullptr;
10731075
ptA->dtor( );

0 commit comments

Comments
 (0)