Commit 96b5dc0b authored by Glauber Costa's avatar Glauber Costa Committed by antirez
Browse files

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.
parent 3d2af579
...@@ -402,7 +402,7 @@ void getRandomHexChars(char *p, unsigned int len) { ...@@ -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. */ /* Turn it into hex digits taking just 4 bits out of 8 for every byte. */
for (j = 0; j < len; j++) for (j = 0; j < len; j++)
p[j] = charset[p[j] & 0x0F]; 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 /* Given the filename, return the absolute path as an SDS string, or NULL
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment