Merge pull request #25641 from vrabaud:lsh

Prevent signed integer overflow in LshTable
This commit is contained in:
Alexander Smorkalov 2024-05-27 15:55:07 +03:00 committed by GitHub
commit c5976f7865
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -424,7 +424,7 @@ inline size_t LshTable<unsigned char>::getKey(const unsigned char* feature) cons
size_t mask_block = mask_[i / sizeof(size_t)];
while (mask_block) {
// Get the lowest set bit in the mask block
size_t lowest_bit = mask_block & (-(ptrdiff_t)mask_block);
size_t lowest_bit = mask_block & ~(mask_block - 1);
// Add it to the current subsignature if necessary
subsignature += (feature_block & lowest_bit) ? bit_index : 0;
// Reset the bit in the mask block