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
This commit is contained in:
@ -59,7 +59,8 @@ PlatformFile CreatePlatformFile(const FilePath& name, int flags,
|
||||
!(flags & PLATFORM_FILE_OPEN_ALWAYS)) {
|
||||
NOTREACHED();
|
||||
errno = EOPNOTSUPP;
|
||||
*error_code = error_code ? PLATFORM_FILE_ERROR_FAILED : PLATFORM_FILE_OK;
|
||||
if (error_code)
|
||||
*error_code = PLATFORM_FILE_ERROR_FAILED;
|
||||
return kInvalidPlatformFileValue;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user