]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Bug PAL10850: A problem in SALOMEDS_Tool::PutStreamToFiles() method : crash
authorvsr <vsr@opencascade.com>
Fri, 9 Dec 2005 15:43:44 +0000 (15:43 +0000)
committervsr <vsr@opencascade.com>
Fri, 9 Dec 2005 15:43:44 +0000 (15:43 +0000)
src/TOOLSDS/SALOMEDS_Tool.cxx

index d36e8740509213c58adb9debf65630dc2ce24772..fa13a1eb42756a3ed27dbcdae66f5ab00c00a053 100644 (file)
@@ -267,15 +267,18 @@ SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
                                const std::string& theToDirectory,
                                const int theNamesOnly)
 {
-  if(theStream.length() == 0) 
-    return NULL;
+  SALOMEDS::ListOfFileNames_var aFiles = new SALOMEDS::ListOfFileNames;
+
+  if(theStream.length() == 0)
+    return aFiles;
 
   //Get a temporary directory for saving a file
   TCollection_AsciiString aTmpDir(const_cast<char*>(theToDirectory.c_str()));
 
   unsigned char *aBuffer = (unsigned char*)theStream.NP_data();
 
-  if(aBuffer == NULL) return NULL;
+  if(aBuffer == NULL)
+    return aFiles;
 
   long aFileSize, aCurrentPos = 4;
   int i, aFileNameSize, aNbFiles = 0;
@@ -283,7 +286,6 @@ SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
   //Copy the number of files in the stream
   memcpy(&aNbFiles, aBuffer, sizeof(int)); 
 
-  SALOMEDS::ListOfFileNames_var aFiles = new SALOMEDS::ListOfFileNames;
   aFiles->length(aNbFiles);
 
   for(i=0; i<aNbFiles; i++) {