diff options
author | antirez <antirez@gmail.com> | 2019-12-18 12:57:32 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2019-12-18 12:57:32 +0100 |
commit | 5a72c5058c27cdc778cde8f61d16691b11a6adc5 (patch) | |
tree | 706e72a41352da008f86af57c28740b3f7842555 /src/geo.c | |
parent | e6e58e455c1adce82592a5dcf276dd8083088e2b (diff) | |
download | redis-5a72c5058c27cdc778cde8f61d16691b11a6adc5.tar.gz |
Fix GEOHASH negative shifting in a more compatible way.
Diffstat (limited to 'src/geo.c')
-rw-r--r-- | src/geo.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -737,7 +737,15 @@ void geohashCommand(client *c) { char buf[12]; int i; for (i = 0; i < 11; i++) { - int idx = (hash.bits >> (52-((i+1)*5))) & 0x1f; + int idx; + if (i == 10) { + /* We have just 52 bits, but the API used to output + * an 11 bytes geohash. For compatibility we assume + * zero. */ + idx = 0; + } else { + idx = (hash.bits >> (52-((i+1)*5))) & 0x1f; + } buf[i] = geoalphabet[idx]; } buf[11] = '\0'; |