Chromium Code Reviews| Index: webrtc/base/helpers.cc |
| diff --git a/webrtc/base/helpers.cc b/webrtc/base/helpers.cc |
| index 0a39ee923e1d61b3db9fa6399aee34049595fff6..450a4407fc853bdcd5f9bf4e04924c83ac89e1e1 100644 |
| --- a/webrtc/base/helpers.cc |
| +++ b/webrtc/base/helpers.cc |
| @@ -219,10 +219,15 @@ std::string CreateRandomString(size_t len) { |
| return str; |
| } |
| -bool CreateRandomString(size_t len, |
| +static bool CreateRandomString(size_t len, |
|
joachim
2016/07/01 22:27:34
Function is not exposed through header, so I chane
|
| const char* table, int table_size, |
| std::string* str) { |
| str->clear(); |
| + // Avoid biased modulo division below. |
| + if (256 % table_size) { |
| + LOG(LS_ERROR) << "Table size must divide 256 evenly!"; |
| + return false; |
| + } |
| std::unique_ptr<uint8_t[]> bytes(new uint8_t[len]); |
| if (!Rng().Generate(bytes.get(), len)) { |
| LOG(LS_ERROR) << "Failed to generate random string!"; |