Skip to content

Commit

Permalink
Don't call sdscmp() with shared.maxstring or shared.minstring
Browse files Browse the repository at this point in the history
  • Loading branch information
israellot committed Mar 12, 2019
1 parent 0a967ec commit b9746ec
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/t_zset.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,12 @@ int zslParseLexRangeItem(robj *item, sds *dest, int *ex) {
switch(c[0]) {
case '+':
if (c[1] != '\0') return C_ERR;
*ex = 0;
*ex = 1;
*dest = shared.maxstring;
return C_OK;
case '-':
if (c[1] != '\0') return C_ERR;
*ex = 0;
*ex = 1;
*dest = shared.minstring;
return C_OK;
case '(':
Expand Down Expand Up @@ -601,9 +601,8 @@ int zslIsInLexRange(zskiplist *zsl, zlexrangespec *range) {
zskiplistNode *x;

/* Test for ranges that will always be empty. */
if (sdscmplex(range->min,range->max) > 1 ||
(sdscmp(range->min,range->max) == 0 &&
(range->minex || range->maxex)))
int cmp = sdscmplex(range->min,range->max);
if (cmp > 0 || (cmp == 0 && (range->minex || range->maxex)))
return 0;
x = zsl->tail;
if (x == NULL || !zslLexValueGteMin(x->ele,range))
Expand Down Expand Up @@ -876,9 +875,8 @@ int zzlIsInLexRange(unsigned char *zl, zlexrangespec *range) {
unsigned char *p;

/* Test for ranges that will always be empty. */
if (sdscmplex(range->min,range->max) > 1 ||
(sdscmp(range->min,range->max) == 0 &&
(range->minex || range->maxex)))
int cmp = sdscmplex(range->min,range->max);
if (cmp > 0 || (cmp == 0 && (range->minex || range->maxex)))
return 0;

p = ziplistIndex(zl,-2); /* Last element. */
Expand Down

0 comments on commit b9746ec

Please sign in to comment.