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

Unified Diff: base/shared_memory_posix.cc

Issue 7222010: Coverity fixes CID=15870,13529 Check pointer before assign, resource leak. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 6 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
« base/platform_file_posix.cc ('K') | « base/platform_file_posix.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/shared_memory_posix.cc
diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc
index 7a238ed880b12a641b7461fc01285b7d169d9cc2..42aef2f33b872c52479249e8d1ab2863714a28dd 100644
--- a/base/shared_memory_posix.cc
+++ b/base/shared_memory_posix.cc
@@ -142,14 +142,20 @@ bool SharedMemory::CreateNamed(const std::string& name,
if (fp && fix_size) {
// Get current size.
struct stat stat;
- if (fstat(fileno(fp), &stat) != 0)
+ if (fstat(fileno(fp), &stat) != 0) {
+ file_util::CloseFile(fp);
rvargas (doing something else) 2011/06/23 03:43:53 nit: it seems ScopedFILE could be used by this met
return false;
+ }
const uint32 current_size = stat.st_size;
if (current_size != size) {
- if (HANDLE_EINTR(ftruncate(fileno(fp), size)) != 0)
+ if (HANDLE_EINTR(ftruncate(fileno(fp), size)) != 0) {
+ file_util::CloseFile(fp);
return false;
- if (fseeko(fp, size, SEEK_SET) != 0)
+ }
+ if (fseeko(fp, size, SEEK_SET) != 0) {
+ file_util::CloseFile(fp);
return false;
+ }
}
created_size_ = size;
}
« base/platform_file_posix.cc ('K') | « base/platform_file_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698