diff options
author | Glauber Costa <glommer@cloudius-systems.com> | 2014-04-08 14:47:50 +0400 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-04-23 15:35:12 +0200 |
commit | 96b5dc0b98cf849e4bba3c9d11f1d978a37dae92 (patch) | |
tree | 76b5abb748d5bb3036dbbb4301f7835d737ac4d9 | |
parent | 3d2af579743be78e54b33855694a696f59c9ed72 (diff) | |
download | redis-96b5dc0b98cf849e4bba3c9d11f1d978a37dae92.tar.gz |
fix null pointer access with no file pointer
I happen to be working on a system that lacks urandom. While the code does try
to handle this case and artificially create some bytes if the file pointer is
empty, it does try to close it unconditionally, leading to a segfault.
-rw-r--r-- | src/util.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c index 37534dfb9..664c82b80 100644 --- a/src/util.c +++ b/src/util.c @@ -402,7 +402,7 @@ void getRandomHexChars(char *p, unsigned int len) { /* Turn it into hex digits taking just 4 bits out of 8 for every byte. */ for (j = 0; j < len; j++) p[j] = charset[p[j] & 0x0F]; - fclose(fp); + if (fp) fclose(fp); } /* Given the filename, return the absolute path as an SDS string, or NULL |