summaryrefslogtreecommitdiffstats
path: root/base/shared_memory_posix.cc
diff options
context:
space:
mode:
authorgbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-27 17:24:27 +0000
committergbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-27 17:24:27 +0000
commit07cbcd68c29b674026adf70cded4149229088bc1 (patch)
tree539cc51f4eac9878faa90c0529e6c9f51057b293 /base/shared_memory_posix.cc
parentd1d18174fc270d9a681b9d718b7ae07fcd33b720 (diff)
downloadchromium_src-07cbcd68c29b674026adf70cded4149229088bc1.zip
chromium_src-07cbcd68c29b674026adf70cded4149229088bc1.tar.gz
chromium_src-07cbcd68c29b674026adf70cded4149229088bc1.tar.bz2
Coverity fixes CID=15870,13529 Check pointer before assign, resource leak.
Review URL: http://codereview.chromium.org/7222010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90599 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/shared_memory_posix.cc')
-rw-r--r--base/shared_memory_posix.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc
index 1580487..f81d88c 100644
--- a/base/shared_memory_posix.cc
+++ b/base/shared_memory_posix.cc
@@ -150,14 +150,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);
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;
}