summaryrefslogtreecommitdiffstats
path: root/base/resource_util.cc
diff options
context:
space:
mode:
authorcpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-08 19:29:12 +0000
committercpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-08 19:29:12 +0000
commit7d0d8af5e43ae5b599f80208606a821b1f0c5482 (patch)
treefa04d3d161ffdcaa4bc7b9d11686a6317ce46ba8 /base/resource_util.cc
parentf24ab372e7f2ace6a67e0d1d3fc02e793202d8e9 (diff)
downloadchromium_src-7d0d8af5e43ae5b599f80208606a821b1f0c5482.zip
chromium_src-7d0d8af5e43ae5b599f80208606a821b1f0c5482.tar.gz
chromium_src-7d0d8af5e43ae5b599f80208606a821b1f0c5482.tar.bz2
Klocwork bug. Checking the wrong variable.
BUG = 3103 Review URL: http://codereview.chromium.org/6453 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3030 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/resource_util.cc')
-rw-r--r--base/resource_util.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/base/resource_util.cc b/base/resource_util.cc
index 7da461d..b9af11f 100644
--- a/base/resource_util.cc
+++ b/base/resource_util.cc
@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/resource_util.h"
-
#include "base/logging.h"
+#include "base/resource_util.h"
namespace base {
bool GetDataResourceFromModule(HMODULE module, int resource_id,
@@ -12,20 +11,26 @@ bool GetDataResourceFromModule(HMODULE module, int resource_id,
if (!module)
return false;
- // Get a pointer to the data in the dll.
- DCHECK(IS_INTRESOURCE(resource_id));
+ if (!IS_INTRESOURCE(resource_id)) {
+ NOTREACHED();
+ return false;
+ }
+
HRSRC hres_info = FindResource(module, MAKEINTRESOURCE(resource_id),
L"BINDATA");
if (NULL == hres_info)
return false;
DWORD data_size = SizeofResource(module, hres_info);
-
HGLOBAL hres = LoadResource(module, hres_info);
- if (!hres_info)
+ if (!hres)
+ return false;
+
+ void* resource = LockResource(hres);
+ if (!resource)
return false;
- *data = LockResource(hres);
+ *data = resource;
*length = static_cast<size_t>(data_size);
return true;
}