mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-11 23:49:38 -05:00
Fix Clang Static Analyser: Undefined allocation of 0 bytes
Unix API: Undefined allocation of 0 bytes (CERT MEM04-C; CWE-131): Call to 'malloc' has an allocation size of 0 bytes 1: Loop body executed 0 times in /home/phenom/GIT/RetroShare/trunk/ libbitdht/src/util/bdbloom.cc:223 2: Calling 'bloomFilter::getFilter' in /home/phenom/GIT/RetroShare/ trunk/libbitdht/src/util/bdbloom.cc:240 3: 'bytes' initialized to 0 in /home/phenom/GIT/RetroShare/trunk/ libbitdht/src/util/bdbloom.cc:141 4: Call to 'malloc' has an allocation size of 0 bytes in /home/phenom/ GIT/RetroShare/trunk/libbitdht/src/util/bdbloom.cc:148
This commit is contained in:
parent
f22dc0f0df
commit
ff1908eda6
@ -144,6 +144,11 @@ std::string bloomFilter::getFilter()
|
||||
bytes++;
|
||||
}
|
||||
|
||||
if (bytes==0)
|
||||
{
|
||||
std::cerr << "(EE) Error. Cannot allocate memory for 0 byte in " << __PRETTY_FUNCTION__ << std::endl;
|
||||
return std::string();
|
||||
}
|
||||
// convert to binary array.
|
||||
uint8_t *tmparray = (uint8_t *) malloc(bytes);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user