]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
more protections against null returned pointer
authorageay <ageay>
Fri, 22 Mar 2013 11:30:16 +0000 (11:30 +0000)
committerageay <ageay>
Fri, 22 Mar 2013 11:30:16 +0000 (11:30 +0000)
src/MEDCoupling_Swig/MEDCouplingCommon.i
src/MEDLoader/Swig/MEDLoaderCommon.i

index 6e461572a5cfa403fa9ff281ab2e37ab555c481f..1de0e431be21a7ab22d77d16b2fe0dc433fea71a 100644 (file)
@@ -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 );
       } 
     }
index e2b7bf265ed0bcd93a1cc7443f57579b95b5f67f..a7ff41ef667cf93daaa7f5de5d27614cdf441e3b 100644 (file)
@@ -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 );
        }