Skip to content

Commit 31663d4

Browse files
committed
Make sure to avoid overflows on 32-bits.
1 parent 04bcecd commit 31663d4

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

redis_array_impl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,10 @@ ra_find_node(RedisArray *ra, const char *key, int key_len, int *out_pos TSRMLS_D
394394
efree(out);
395395

396396
/* get position on ring */
397-
pos = (int)((((uint64_t)hash) * ra->count) / 0xffffffff);
397+
uint64_t h64 = hash;
398+
h64 *= ra->count;
399+
h64 /= 0xffffffff;
400+
pos = (int)h64;
398401
}
399402
if(out_pos) *out_pos = pos;
400403

0 commit comments

Comments
 (0)