Salome HOME
PAL10195: SALOME V2 study with a mesh leads to SIGSEGV of SALOME V3
[modules/smesh.git] / src / SMESH_I / SMESH_Gen_i.cxx
index 1817f0e237eb182632022c79e1755a9850c2651d..1abae770956088b645ca49d7ae224f8c78150dcf 100644 (file)
@@ -1544,14 +1544,15 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
                   // Write datasets
                   if ( nbNodes )
                   {
-                    aSize[ 0 ] = nbNodes;
+                    aSize[ 0 ] = nbNodes*sizeof(int);
                     // IDS
                     string aDSName( onFace ? "Nodes on Faces" : "Nodes on Edges");
-                    aDataset = new HDFdataset( (char*)aDSName.c_str(), aGroup, HDF_INT32, aSize, 1 );
+                    aDataset = new HDFdataset( (char*)aDSName.c_str(), aGroup, HDF_STRING, aSize, 1 );
                     aDataset->CreateOnDisk();
                     aDataset->WriteOnDisk( aNodeIDs );
                     aDataset->CloseOnDisk();
 
+                   aSize[ 0 ] = nbNodes;
                     // U Positions
                     aDSName = ( onFace ? "Face U positions" : "Edge positions");
                     aDataset = new HDFdataset( (char*)aDSName.c_str(), aGroup, HDF_FLOAT64, aSize, 1);
@@ -1738,7 +1739,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
              char* hypname_str = new char[ size ];
              aDataset->ReadFromDisk( hypname_str );
              hypname = string( hypname_str );
-             delete hypname_str;
+             delete [] hypname_str;
              aDataset->CloseOnDisk();
            }
            // --> get hypothesis plugin library name
@@ -1750,7 +1751,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
              aDataset->ReadFromDisk( libname_str );
              if(MYDEBUG) SCRUTE( libname_str );
              libname = string( libname_str );
-             delete libname_str;
+             delete [] libname_str;
              aDataset->CloseOnDisk();
            }
            // --> get hypothesis data
@@ -1761,7 +1762,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
              char* hypdata_str = new char[ size ];
              aDataset->ReadFromDisk( hypdata_str );
              hypdata = string( hypdata_str );
-             delete hypdata_str;
+             delete [] hypdata_str;
              aDataset->CloseOnDisk();
            }
          }
@@ -1835,7 +1836,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
              char* hypname_str = new char[ size ];
              aDataset->ReadFromDisk( hypname_str );
              hypname = string( hypname_str );
-             delete hypname_str;
+             delete [] hypname_str;
              aDataset->CloseOnDisk();
            }
            // --> get algorithm plugin library name
@@ -1847,7 +1848,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
              aDataset->ReadFromDisk( libname_str );
              if(MYDEBUG) SCRUTE( libname_str );
              libname = string( libname_str );
-             delete libname_str;
+             delete [] libname_str;
              aDataset->CloseOnDisk();
            }
            // --> get algorithm data
@@ -1859,7 +1860,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
              aDataset->ReadFromDisk( hypdata_str );
              if(MYDEBUG) SCRUTE( hypdata_str );
              hypdata = string( hypdata_str );
-             delete hypdata_str;
+             delete [] hypdata_str;
              aDataset->CloseOnDisk();
            }
          }
@@ -2271,16 +2272,20 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
                 }
                 else // NODE IDS
                 {
-                  int* ids = new int [ aDataset->GetSize() ];
+                 //PAL10195:int aSize = aDataset->GetSize()/sizeof(int);
+                 int aSize = aDataset->GetSize();       //PAL10195
+                  if (aDataset->GetType() == HDF_STRING) //PAL10195
+                    aSize /= sizeof(int);                //PAL10195
+                 int* ids = new int [aSize];
                   aDataset->ReadFromDisk( ids );
                   // on face or nodes?
                   if ( strncmp( aDSName, aEid_DSName, strlen( aEid_DSName )) == 0 ) {
                     aEids = ids;
-                    nbEids = aDataset->GetSize();
+                    nbEids = aSize;
                   }
                   else {
                     aFids = ids;
-                    nbFids = aDataset->GetSize();
+                    nbFids = aSize;
                   }
                 }
               } // loop on 5 datasets