mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-08 06:32:55 -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
|
@ -315,7 +315,11 @@ int pqistreamer::queue_outpqi_locked(RsItem *pqi,uint32_t& pktsize)
|
|||
/* decide which type of packet it is */
|
||||
|
||||
pktsize = mRsSerialiser->size(pqi);
|
||||
void *ptr = malloc(pktsize);
|
||||
void *ptr = rs_safe_malloc(pktsize);
|
||||
|
||||
if(ptr == NULL)
|
||||
return 0 ;
|
||||
|
||||
|
||||
#ifdef DEBUG_PQISTREAMER
|
||||
std::cerr << "pqistreamer::queue_outpqi() serializing packet with packet size : " << pktsize << std::endl;
|
||||
|
@ -1040,7 +1044,10 @@ void pqistreamer::allocate_rpend_locked()
|
|||
return;
|
||||
|
||||
mPkt_rpend_size = getRsPktMaxSize();
|
||||
mPkt_rpending = malloc(mPkt_rpend_size);
|
||||
mPkt_rpending = rs_safe_malloc(mPkt_rpend_size);
|
||||
|
||||
if(mPkt_rpending == NULL)
|
||||
return ;
|
||||
|
||||
// avoid uninitialized (and random) memory read.
|
||||
memset(mPkt_rpending,0,mPkt_rpend_size) ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue