Skip to content


Subversion checkout URL

You can clone with
Download ZIP


fix srandmemberWithCountCommand bug in t_set.c #777

wants to merge 2 commits into from

3 participants


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.


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()");

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
3  src/t_set.c
@@ -481,7 +481,10 @@ void srandmemberWithCountCommand(redisClient *c) {
} else if (ele->encoding == REDIS_ENCODING_INT) {
retval = dictAdd(d,
+ } else {
+ redisPanic("unexpected encoding in returned by setTypeNext()");
redisAssert(retval == DICT_OK);
Something went wrong with that request. Please try again.