UnrealLoader: Fix IOStream leak
authorTuro Lamminen <turotl@gmail.com>
Thu, 5 Oct 2017 08:56:13 +0000 (11:56 +0300)
committerTuro Lamminen <turotl@gmail.com>
Thu, 5 Oct 2017 09:15:28 +0000 (12:15 +0300)
code/UnrealLoader.cpp

index c8382cb..a79a2a5 100644 (file)
@@ -157,7 +157,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
     DefaultLogger::get()->debug("UNREAL: uc file is "   + uc_path);
 
     // and open the files ... we can't live without them
-    IOStream* p = pIOHandler->Open(d_path);
+    std::unique_ptr<IOStream> p(pIOHandler->Open(d_path));
     if (!p)
         throw DeadlyImportError("UNREAL: Unable to open _d file");
     StreamReaderLE d_reader(pIOHandler->Open(d_path));
@@ -203,7 +203,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
         d_reader.IncPtr(1);
     }
 
-    p = pIOHandler->Open(a_path);
+    p.reset(pIOHandler->Open(a_path));
     if (!p)
         throw DeadlyImportError("UNREAL: Unable to open _a file");
     StreamReaderLE a_reader(pIOHandler->Open(a_path));