mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 14:12:43 -04:00
added a new method rs_malloc that checks its arguments and prints a stacktrace on error/weird call. Changed the code everywhere to use this instead of malloc. Removed some mallocs and replaced with RsTemporaryMemory
This commit is contained in:
parent
9c6e7dfc13
commit
d13526facd
39 changed files with 274 additions and 132 deletions
|
@ -34,6 +34,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "util/rsmemory.h"
|
||||
#include "retroshare/rstypes.h"
|
||||
|
||||
/*******************************************************************
|
||||
|
@ -181,7 +182,7 @@ class RsRawItem: public RsItem
|
|||
RsRawItem(uint32_t t, uint32_t size)
|
||||
:RsItem(t), len(size)
|
||||
{
|
||||
data = malloc(len);
|
||||
data = rs_safe_malloc(len);
|
||||
}
|
||||
|
||||
virtual ~RsRawItem()
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "util/rsmemory.h"
|
||||
#include "serialiser/rstlvbinary.h"
|
||||
|
||||
#include "serialiser/rstlvbase.h"
|
||||
|
@ -74,7 +75,11 @@ bool RsTlvBinaryData::setBinData(const void *data, uint32_t size)
|
|||
return true;
|
||||
}
|
||||
|
||||
bin_data = malloc(bin_len);
|
||||
bin_data = rs_safe_malloc(bin_len);
|
||||
|
||||
if(bin_data == NULL)
|
||||
return false ;
|
||||
|
||||
memcpy(bin_data, data, bin_len);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue