Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fix srandmemberWithCountCommand bug in t_set.c #777

Open
wants to merge 2 commits into from

3 participants

@charsyam

in 475 line, retval is not initialized.. because of it.

if encoding is not match below if cases.

it can pass redisAssert statement. it can be initialized as DICT_OK.

@antirez
Owner

Hi @charsyam, I think that while the code can be improved, initializing the variable is not the right solution.

What I mean is that, currently, setTypeNext() can only return one of the three encodings covered, so if we want to embrace defensive programming I would patch it adding an:

else {
    redisPanic("unexpected encoding in returned by setTypeNext()");
}
@charsyam

Yes, I totally agree with you. so I applied your opinion. I changed my patch according to your opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 19, 2012
  1. @openbaas
  2. @openbaas

    add redisPanic

    openbaas authored
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 0 deletions.
  1. +3 −0  src/t_set.c
View
3  src/t_set.c
@@ -481,7 +481,10 @@ void srandmemberWithCountCommand(redisClient *c) {
} else if (ele->encoding == REDIS_ENCODING_INT) {
retval = dictAdd(d,
createStringObjectFromLongLong((long)ele->ptr),NULL);
+ } else {
+ redisPanic("unexpected encoding in returned by setTypeNext()");
}
+
redisAssert(retval == DICT_OK);
}
setTypeReleaseIterator(si);
Something went wrong with that request. Please try again.