Chromium Code Reviews| Index: chrome_elf/blacklist/blacklist.cc |
| diff --git a/chrome_elf/blacklist/blacklist.cc b/chrome_elf/blacklist/blacklist.cc |
| index eda611db41eba3a80f35c9f15964aaaa1c6bf47e..a720960820163e356744fad165a5f16683584aeb 100644 |
| --- a/chrome_elf/blacklist/blacklist.cc |
| +++ b/chrome_elf/blacklist/blacklist.cc |
| @@ -19,8 +19,11 @@ extern "C" IMAGE_DOS_HEADER __ImageBase; |
| namespace blacklist{ |
| -const wchar_t* g_troublesome_dlls[kTroublesomeDllsMaxCount] = {}; |
| -int g_troublesome_dlls_cur_index = 0; |
| +const wchar_t* g_troublesome_dlls[kTroublesomeDllsMaxCount] = { |
| + L"libsvn_tsvn32.dll", |
|
robertshield
2014/01/24 16:38:35
Do you want to move just the above line to a separ
csharp
2014/01/24 16:42:08
Done.
|
| + // Keep this null pointer here to mark the end of the list. |
| + NULL, |
| +}; |
| const wchar_t kRegistryBeaconPath[] = L"SOFTWARE\\Google\\Chrome\\BLBeacon"; |
| const wchar_t kBeaconVersion[] = L"version"; |
| @@ -233,11 +236,20 @@ bool ResetBeacon() { |
| return (result == ERROR_SUCCESS); |
| } |
| +int BlacklistSize() { |
| + int size = 0; |
| + while(blacklist::g_troublesome_dlls[++size] != NULL); |
| + |
| + return size; |
| +} |
| + |
| bool AddDllToBlacklist(const wchar_t* dll_name) { |
| - if (g_troublesome_dlls_cur_index >= kTroublesomeDllsMaxCount) |
| + int blacklist_size = BlacklistSize(); |
| + // We need to leave one space at the end for the null pointer. |
| + if (blacklist_size + 1 >= kTroublesomeDllsMaxCount) |
| return false; |
| - for (int i = 0; i < g_troublesome_dlls_cur_index; ++i) { |
| - if (!wcscmp(g_troublesome_dlls[i], dll_name)) |
| + for (int i=0; i < blacklist_size; ++i) { |
| + if (!_wcsicmp(g_troublesome_dlls[i], dll_name)) |
| return true; |
| } |
| @@ -245,20 +257,19 @@ bool AddDllToBlacklist(const wchar_t* dll_name) { |
| wchar_t* str_buffer = new wchar_t[wcslen(dll_name) + 1]; |
| wcscpy(str_buffer, dll_name); |
| - g_troublesome_dlls[g_troublesome_dlls_cur_index] = str_buffer; |
| - g_troublesome_dlls_cur_index++; |
| + g_troublesome_dlls[blacklist_size] = str_buffer; |
| return true; |
| } |
| bool RemoveDllFromBlacklist(const wchar_t* dll_name) { |
| - for (int i = 0; i < g_troublesome_dlls_cur_index; ++i) { |
| - if (!wcscmp(g_troublesome_dlls[i], dll_name)) { |
| + int blacklist_size = BlacklistSize(); |
| + for (int i = 0; i < blacklist_size; ++i) { |
| + if (!_wcsicmp(g_troublesome_dlls[i], dll_name)) { |
| // Found the thing to remove. Delete it then replace it with the last |
| // element. |
| - g_troublesome_dlls_cur_index--; |
| delete[] g_troublesome_dlls[i]; |
| - g_troublesome_dlls[i] = g_troublesome_dlls[g_troublesome_dlls_cur_index]; |
| - g_troublesome_dlls[g_troublesome_dlls_cur_index] = NULL; |
| + g_troublesome_dlls[i] = g_troublesome_dlls[blacklist_size - 1]; |
| + g_troublesome_dlls[blacklist_size - 1] = NULL; |
| return true; |
| } |
| } |