From fe0c698838a5ec46379cad1ff54afe69d7fb2cb0 Mon Sep 17 00:00:00 2001 From: ageay Date: Fri, 22 Mar 2013 11:30:16 +0000 Subject: [PATCH] more protections against null returned pointer --- src/MEDCoupling_Swig/MEDCouplingCommon.i | 9 ++++++--- src/MEDLoader/Swig/MEDLoaderCommon.i | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 6e461572a..1de0e431b 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -3513,19 +3513,22 @@ namespace ParaMEDMEM PyObject *getMesh2D() const throw(INTERP_KERNEL::Exception) { MEDCouplingUMesh *ret=self->getMesh2D(); - ret->incrRef(); + if(ret) + ret->incrRef(); return convertMesh(ret, SWIG_POINTER_OWN | 0 ); } PyObject *getMesh1D() const throw(INTERP_KERNEL::Exception) { MEDCouplingUMesh *ret=self->getMesh1D(); - ret->incrRef(); + if(ret) + ret->incrRef(); return convertMesh(ret, SWIG_POINTER_OWN | 0 ); } PyObject *getMesh3DIds() const throw(INTERP_KERNEL::Exception) { DataArrayInt *ret=self->getMesh3DIds(); - ret->incrRef(); + if(ret) + ret->incrRef(); return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); } } diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index e2b7bf265..a7ff41ef6 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -955,14 +955,16 @@ namespace ParaMEDMEM PyObject *getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception) { const MEDFileFieldLoc *loc=&self->getLocalizationFromId(locId); - loc->incrRef(); + if(loc) + loc->incrRef(); return SWIG_NewPointerObj(SWIG_as_voidptr(loc),SWIGTYPE_p_ParaMEDMEM__MEDFileFieldLoc, SWIG_POINTER_OWN | 0 ); } PyObject *getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception) { const MEDFileFieldLoc *loc=&self->getLocalization(locName); - loc->incrRef(); + if(loc) + loc->incrRef(); return SWIG_NewPointerObj(SWIG_as_voidptr(loc),SWIGTYPE_p_ParaMEDMEM__MEDFileFieldLoc, SWIG_POINTER_OWN | 0 ); } -- 2.39.2