rand: add a clang-analyzer work-around

scan-build would warn on a potential access of an uninitialized
buffer. I deem it a false positive and had to add this somewhat ugly
work-around to silence it.
This commit is contained in:
Daniel Stenberg 2017-12-13 00:45:42 +01:00
parent 13ce373a5b
commit 02f207a76b
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
1 changed files with 6 additions and 0 deletions

View File

@ -157,6 +157,12 @@ CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd,
unsigned char *bufp = buffer;
#ifdef __clang_analyzer__
/* This silences a scan-build warning about accesssing this buffer with
uninitialized memory. */
memset(buffer, 0, sizeof(buffer));
if((num/2 >= sizeof(buffer)) || !(num&1))
/* make sure it fits in the local buffer and that it is an odd number! */