mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
fix compare function of ziplist to only load integer from ziplist when it is encoded as integer
This commit is contained in:
parent
6205b46387
commit
c4aace9003
15
ziplist.c
15
ziplist.c
@ -374,19 +374,24 @@ unsigned int ziplistCompare(unsigned char *p, unsigned char *entry, unsigned int
|
|||||||
if (*p == ZIP_END) return 0;
|
if (*p == ZIP_END) return 0;
|
||||||
|
|
||||||
zlen = zipDecodeLength(p,&lensize);
|
zlen = zipDecodeLength(p,&lensize);
|
||||||
if (zipTryEncoding(entry,&eval,&encoding)) {
|
if (ZIP_ENCODING(p) == ZIP_ENC_RAW) {
|
||||||
/* Do integer compare */
|
|
||||||
zval = zipLoadInteger(p+lensize,ZIP_ENCODING(p));
|
|
||||||
return zval == eval;
|
|
||||||
} else {
|
|
||||||
/* Raw compare */
|
/* Raw compare */
|
||||||
if (zlen == elen) {
|
if (zlen == elen) {
|
||||||
return memcmp(p+lensize,entry,elen) == 0;
|
return memcmp(p+lensize,entry,elen) == 0;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (zipTryEncoding(entry,&eval,&encoding)) {
|
||||||
|
/* Do integer compare */
|
||||||
|
zval = zipLoadInteger(p+lensize,ZIP_ENCODING(p));
|
||||||
|
return zval == eval;
|
||||||
|
} else {
|
||||||
|
/* Ziplist entry is integer encoded, but given entry is not. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Return length of ziplist. */
|
/* Return length of ziplist. */
|
||||||
unsigned int ziplistLen(unsigned char *zl) {
|
unsigned int ziplistLen(unsigned char *zl) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user