diff options
author | antirez <antirez@gmail.com> | 2015-01-22 11:00:26 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2015-01-22 11:00:26 +0100 |
commit | 9826038f0bb41a79b2ab06fd7e5f1ffa745b7156 (patch) | |
tree | 3daa34d78b4af8143a407ccf7e1eed816efdeed3 /src/util.c | |
parent | 87301be15152bd3627c9e87533c2c96fa9d4fd67 (diff) | |
download | redis-9826038f0bb41a79b2ab06fd7e5f1ffa745b7156.tar.gz |
counter must be static in getRandomHexChars().
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/util.c b/src/util.c index 0a2307c9b..f995bf1ea 100644 --- a/src/util.c +++ b/src/util.c @@ -431,9 +431,11 @@ int d2string(char *buf, size_t len, double value) { void getRandomHexChars(char *p, unsigned int len) { char *charset = "0123456789abcdef"; unsigned int j; - static int seed_initialized = 0; unsigned char seed[20]; /* A seed to have a different sequence each run. */ - uint64_t counter = 0; /* The counter we hash together with the seed. */ + + /* Global state. */ + static int seed_initialized = 0; + static uint64_t counter = 0; /* The counter we hash with the seed. */ if (!seed_initialized) { /* Initialize a seed and use SHA1 in counter mode, where we hash |