diff options
author | Alon Diamant <alon@everything.me> | 2014-12-18 12:39:58 +0200 |
---|---|---|
committer | Alon Diamant <alon@everything.me> | 2014-12-18 14:38:20 +0200 |
commit | 3c8a75583dd896c6b9f31b72fa394962650b8547 (patch) | |
tree | d5d5ed0db4a83de3651ab3424a255ec2fede8ab3 /src/t_set.c | |
parent | 288028876f4428edfc044d8a1f1d6784b0dbe739 (diff) | |
download | redis-3c8a75583dd896c6b9f31b72fa394962650b8547.tar.gz |
Fix: case when SPOP with count>MAXINT, setTypeRandomElements() will get negative count argument due to signed/unsigned mismatch.
setTypeRandomElements() now returns unsigned long, and also uses unsigned long for anything related to count of members.
spopWithCountCommand() now uses unsigned long elements_returned instead of int, for values returned from setTypeRandomElements()
Diffstat (limited to 'src/t_set.c')
-rw-r--r-- | src/t_set.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/t_set.c b/src/t_set.c index 757450c9d..006d29b8c 100644 --- a/src/t_set.c +++ b/src/t_set.c @@ -225,11 +225,11 @@ int setTypeRandomElement(robj *setobj, robj **objele, int64_t *llele) { * at producing N elements, and the elements are guaranteed to be non * repeating. */ -int setTypeRandomElements(robj *set, int count, robj *aux_set) { - int set_size; - int elements_to_return = count; - int elements_copied = 0; - int current_element = 0; +unsigned long setTypeRandomElements(robj *set, unsigned long count, robj *aux_set) { + unsigned long set_size; + unsigned long elements_to_return = count; + unsigned long elements_copied = 0; + unsigned long current_element = 0; /* Like all setType* functions, we assume good behavior on part of the caller, * so no extra parameter checks are made. */ @@ -480,7 +480,7 @@ void scardCommand(redisClient *c) { void spopWithCountCommand(redisClient *c) { long l; unsigned long count, size; - int elements_returned; + unsigned long elements_returned; robj *set, *aux, *aux_set; int64_t llele; |