mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-22 21:34:32 -04:00
added checks after mallocs in several files
This commit is contained in:
parent
46520b0e22
commit
9c6e7dfc13
15 changed files with 157 additions and 12 deletions
|
@ -66,7 +66,11 @@ class udpPacket
|
|||
:raddr(*addr), len(dlen)
|
||||
{
|
||||
data = malloc(len);
|
||||
memcpy(data, dta, len);
|
||||
|
||||
if(data != NULL)
|
||||
memcpy(data, dta, len);
|
||||
else
|
||||
std::cerr << "(EE) error in memory allocation in " << __PRETTY_FUNCTION__ << std::endl;
|
||||
}
|
||||
|
||||
~udpPacket()
|
||||
|
@ -242,6 +246,12 @@ void UdpLayer::recv_loop()
|
|||
int maxsize = 16000;
|
||||
void *inbuf = malloc(maxsize);
|
||||
|
||||
if(inbuf == NULL)
|
||||
{
|
||||
std::cerr << "(EE) Error in memory allocation of size " << maxsize << " in " << __PRETTY_FUNCTION__ << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
int status;
|
||||
struct timeval timeout;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue