Plug a leak in the non-error case by removing one level of indirection.
authorNick Lewycky <nicholas@mxc.ca>
Mon, 7 Jun 2010 21:42:19 +0000 (21:42 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Mon, 7 Jun 2010 21:42:19 +0000 (21:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105556 91177308-0d34-0410-b5e6-96231b3b80d8

tools/gold/gold-plugin.cpp

index 3f0b55597af42391907b0567e302b9da3e9e40b9..2b055a2272feeac55acc4c8ef349b12c5b094ff2 100644 (file)
@@ -419,17 +419,15 @@ static ld_plugin_status all_symbols_read_hook(void) {
     (*message)(LDPL_ERROR, "%s", ErrMsg.c_str());
     return LDPS_ERR;
   }
-  raw_fd_ostream *objFile =
-    new raw_fd_ostream(uniqueObjPath.c_str(), ErrMsg,
-                       raw_fd_ostream::F_Binary);
+  raw_fd_ostream objFile(uniqueObjPath.c_str(), ErrMsg,
+                         raw_fd_ostream::F_Binary);
   if (!ErrMsg.empty()) {
-    delete objFile;
     (*message)(LDPL_ERROR, "%s", ErrMsg.c_str());
     return LDPS_ERR;
   }
 
-  objFile->write(buffer, bufsize);
-  objFile->close();
+  objFile.write(buffer, bufsize);
+  objFile.close();
 
   lto_codegen_dispose(cg);