Skip to content


Subversion checkout URL

You can clone with
Download ZIP


fix randstring bug in ziplist.c #776

merged 1 commit into from

3 participants


p is not initialized. but After fixing it, I found no one use randstring

but It is obviously bug. so I sent a patch.


because of uninitialized value p, randstring will broke memory.

while(p < len)
target[p++] = minval+rand()%(maxval-minval+1);

@antirez antirez merged commit 7d626d4 into antirez:unstable

Thanks, merged

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

    fix randstring bug

    openbaas authored
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 1 deletion.
  1. +2 −1  src/ziplist.c
3  src/ziplist.c
@@ -1041,7 +1041,8 @@ void pop(unsigned char *zl, int where) {
int randstring(char *target, unsigned int min, unsigned int max) {
- int p, len = min+rand()%(max-min+1);
+ int p = 0;
+ int len = min+rand()%(max-min+1);
int minval, maxval;
switch(rand() % 3) {
case 0:
Something went wrong with that request. Please try again.