Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4128)

Unified Diff: chrome/browser/sessions/session_backend.cc

Issue 2924014: Coverity: Fix leak in SessionBackend::OpenAndWriteHeader on error conditions. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/session_backend.cc
diff --git a/chrome/browser/sessions/session_backend.cc b/chrome/browser/sessions/session_backend.cc
index dfb1200c043ea47d516723ba010a389f9a7326e9..c06f81187963af90f225698a95ab3338502b1850 100644
--- a/chrome/browser/sessions/session_backend.cc
+++ b/chrome/browser/sessions/session_backend.cc
@@ -352,7 +352,7 @@ void SessionBackend::ResetFile() {
net::FileStream* SessionBackend::OpenAndWriteHeader(const FilePath& path) {
DCHECK(!path.empty());
- net::FileStream* file = new net::FileStream();
+ scoped_ptr<net::FileStream> file(new net::FileStream());
file->Open(path, base::PLATFORM_FILE_CREATE_ALWAYS |
base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE |
base::PLATFORM_FILE_EXCLUSIVE_READ);
@@ -365,7 +365,7 @@ net::FileStream* SessionBackend::OpenAndWriteHeader(const FilePath& path) {
sizeof(header), NULL);
if (wrote != sizeof_header())
return NULL;
- return file;
+ return file.release();
}
FilePath SessionBackend::GetLastSessionPath() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698