Salome HOME
PR: merge from branch BR_3_1_0deb tag mergeto_trunk_22dec05
[modules/kernel.git] / 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++) {