Skip to content

Commit

Permalink
counter must be static in getRandomHexChars().
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Jan 22, 2015
1 parent 87301be commit 9826038
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9826038

Please sign in to comment.