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

Unified Diff: base/platform_file_posix.cc

Issue 9873005: [Coverity] Fix possible leak. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed (c) year Created 8 years, 9 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: base/platform_file_posix.cc
diff --git a/base/platform_file_posix.cc b/base/platform_file_posix.cc
index 1f50cfe06208aa1b16317a6792cfaf8513a6e7c1..9b42c7a184fea0d22ee060e1e3022c87325686c3 100644
--- a/base/platform_file_posix.cc
+++ b/base/platform_file_posix.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -89,7 +89,7 @@ PlatformFile CreatePlatformFile(const FilePath& name, int flags,
HANDLE_EINTR(open(name.value().c_str(), open_flags, mode));
if (flags & PLATFORM_FILE_OPEN_ALWAYS) {
- if (descriptor <= 0) {
+ if (descriptor < 0) {
open_flags |= O_CREAT;
if (flags & PLATFORM_FILE_EXCLUSIVE_READ ||
flags & PLATFORM_FILE_EXCLUSIVE_WRITE) {
@@ -97,16 +97,16 @@ PlatformFile CreatePlatformFile(const FilePath& name, int flags,
}
descriptor = HANDLE_EINTR(
open(name.value().c_str(), open_flags, mode));
- if (created && descriptor > 0)
+ if (created && descriptor >= 0)
*created = true;
}
}
- if (created && (descriptor > 0) &&
+ if (created && (descriptor >= 0) &&
(flags & (PLATFORM_FILE_CREATE_ALWAYS | PLATFORM_FILE_CREATE)))
*created = true;
- if ((descriptor > 0) && (flags & PLATFORM_FILE_DELETE_ON_CLOSE)) {
+ if ((descriptor >= 0) && (flags & PLATFORM_FILE_DELETE_ON_CLOSE)) {
unlink(name.value().c_str());
}
« 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