Commit c4aace90 authored by Pieter Noordhuis's avatar Pieter Noordhuis
Browse files

fix compare function of ziplist to only load integer from ziplist when it is encoded as integer

parent 6205b463
......@@ -374,18 +374,23 @@ unsigned int ziplistCompare(unsigned char *p, unsigned char *entry, unsigned int
if (*p == ZIP_END) return 0;
zlen = zipDecodeLength(p,&lensize);
if (zipTryEncoding(entry,&eval,&encoding)) {
/* Do integer compare */
zval = zipLoadInteger(p+lensize,ZIP_ENCODING(p));
return zval == eval;
} else {
if (ZIP_ENCODING(p) == ZIP_ENC_RAW) {
/* Raw compare */
if (zlen == elen) {
return memcmp(p+lensize,entry,elen) == 0;
} else {
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. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment