Skip to content

Commit

Permalink
Fixing error checking of PathService::Get.
Browse files Browse the repository at this point in the history
The return value of PathService::Get was being checked with the FAILED()
macro which is intended for use with HRESULT return types. Because
PathService::Get returns a bool and FAILED treats all non-negative
numbers as success, failures will never be detected.

This was found by VC++'s /analyze which said:
src\cloud_print\virtual_driver\win\install\setup.cc(510) : warning C6215:
Cast between semantically different integer types:  a Boolean type to
HRESULT.

The original bug was introduced
by https://chromiumcodereview.appspot.com/11876005

BUG=427616

Review URL: https://codereview.chromium.org/740463006

Cr-Commit-Position: refs/heads/master@{#307280}
  • Loading branch information
randomascii authored and Commit bot committed Dec 8, 2014
1 parent 7a21135 commit 251dd9b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cloud_print/virtual_driver/win/install/setup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ HRESULT ExecuteCommands() {
*base::CommandLine::ForCurrentProcess();

base::FilePath exe_path;
if (FAILED(PathService::Get(base::DIR_EXE, &exe_path)) ||
if (!PathService::Get(base::DIR_EXE, &exe_path) ||
!base::DirectoryExists(exe_path)) {
return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
}
Expand Down

0 comments on commit 251dd9b

Please sign in to comment.