提交 96b5dc0b 编写于 作者: G Glauber Costa 提交者: antirez

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.
上级 3d2af579
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册