Skip to content

Commit

Permalink
Fix two minor bugs found by /analyze
Browse files Browse the repository at this point in the history
BUG=427616

/analyze pointed out that the loop range-check used the comma operator
when && was probably intended. The bug was harmless, but confusing, so
I fixed it.

/analyze also pointed out that the code was checking data read by a
function and then checking whether the read succeeded. Reversing the
order of the checks has no effect except to get rid of the undefined
behavior.

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

Cr-Commit-Position: refs/heads/master@{#301691}
  • Loading branch information
randomascii authored and Commit bot committed Oct 28, 2014
1 parent 0eabca9 commit 1fd77f5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions chrome_elf/blacklist/blacklist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ bool LeaveSetupBeacon() {
reinterpret_cast<LPBYTE>(&blacklist_state),
&blacklist_state_size);

if (blacklist_state == BLACKLIST_DISABLED || result != ERROR_SUCCESS ||
if (result != ERROR_SUCCESS || blacklist_state == BLACKLIST_DISABLED ||
type != REG_DWORD) {
::RegCloseKey(key);
return false;
Expand Down Expand Up @@ -227,7 +227,7 @@ bool IsBlacklistInitialized() {
}

int GetBlacklistIndex(const wchar_t* dll_name) {
for (int i = 0; i < kTroublesomeDllsMaxCount, g_troublesome_dlls[i]; ++i) {
for (int i = 0; i < kTroublesomeDllsMaxCount && g_troublesome_dlls[i]; ++i) {
if (_wcsicmp(dll_name, g_troublesome_dlls[i]) == 0)
return i;
}
Expand Down

0 comments on commit 1fd77f5

Please sign in to comment.