Project

General

Profile

Actions

Bug #4819

closed

murmurHash3: size_t used for negative values

Added by Anonymous almost 6 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Low
Target version:
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.

Actions

Also available in: Atom PDF