summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/entry_impl.cc
diff options
context:
space:
mode:
authortbreisacher@chromium.org <tbreisacher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 02:43:33 +0000
committertbreisacher@chromium.org <tbreisacher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 02:43:33 +0000
commitc3b5987d2b2c8a005051afc39afb2466dd37dcd5 (patch)
tree081ed70ac4697ed3b3920bbb5bbb5c50d9e42e9d /net/disk_cache/entry_impl.cc
parent6f24c54d4e462bc05d21208ed79ad3ca03f501cc (diff)
downloadchromium_src-c3b5987d2b2c8a005051afc39afb2466dd37dcd5.zip
chromium_src-c3b5987d2b2c8a005051afc39afb2466dd37dcd5.tar.gz
chromium_src-c3b5987d2b2c8a005051afc39afb2466dd37dcd5.tar.bz2
[Coverity] Do key_file NULL check earlier
CID=100673 BUG=none TEST=none Review URL: http://codereview.chromium.org/9290029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119347 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/entry_impl.cc')
-rw-r--r--net/disk_cache/entry_impl.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc
index ad745a7..5996912 100644
--- a/net/disk_cache/entry_impl.cc
+++ b/net/disk_cache/entry_impl.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.
@@ -771,12 +771,14 @@ std::string EntryImpl::GetKey() const {
COMPILE_ASSERT(kNumStreams == kKeyFileIndex, invalid_key_index);
File* key_file = const_cast<EntryImpl*>(this)->GetBackingFile(address,
kKeyFileIndex);
+ if (!key_file)
+ return std::string();
++key_len; // We store a trailing \0 on disk that we read back below.
if (!offset && key_file->GetLength() != static_cast<size_t>(key_len))
return std::string();
- if (!key_file || !key_file->Read(WriteInto(&key_, key_len), key_len, offset))
+ if (!key_file->Read(WriteInto(&key_, key_len), key_len, offset))
key_.clear();
return key_;
}