Actions
Bug #4819
closedmurmurHash3: size_t used for negative values
Start date:
Due date:
% Done:
0%
Estimated time:
Description
murmurHash3 has a for loop that indexes an array with a negative offset from the end of the array. In your implementation, you use an index of type size_t:
https://github.com/named-data/PSync/blob/0cf4b600e91455ee07c38eb22876aa6b653bc14b/PSync/detail/util.cpp#L49
for (size_t i = -nblocks; i; i++) {
uint32_t k1 = blocks[i];
But size_t is an unsigned integer. It's a little weird to use it for negative values because it's stored as a large positive number. For the moment, you are getting lucky and the integer math for blocks[i] works out. But maybe some platform or C++ compiler wouldn't do the right thing. The original code uses "int i". Maybe that is better.
This issue is a low priority comment. Feel free to abandon it.
Updated by Davide Pesavento almost 3 years ago
- Status changed from New to Closed
- Assignee set to Davide Pesavento
- Target version set to v0.3.0
- Start date deleted (
01/28/2019)
This was fixed in commit db7895644a3a73dbc863c655a0dacea076e563d0
Actions