From d55993d1e401075961ce53ca9e91a5cfcc683873 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 12 Jan 2016 21:43:04 -0500 Subject: [PATCH] removed two instances of malloc(0) captured by new rs_malloc funtion --- libretroshare/src/dbase/fimonitor.cc | 2 +- libretroshare/src/ft/ftcontroller.cc | 2 +- libretroshare/src/ft/ftdatamultiplex.cc | 2 +- libretroshare/src/ft/ftserver.cc | 2 +- libretroshare/src/ft/ftturtlefiletransferitem.cc | 2 +- libretroshare/src/grouter/grouteritems.cc | 6 +++--- libretroshare/src/grouter/grouteritems.h | 2 +- libretroshare/src/grouter/p3grouter.cc | 6 +++--- libretroshare/src/gxs/gxssecurity.cc | 8 ++++---- libretroshare/src/gxstunnel/p3gxstunnel.cc | 6 +++--- libretroshare/src/gxstunnel/rsgxstunnelitems.cc | 2 +- libretroshare/src/pgp/pgphandler.cc | 2 +- libretroshare/src/pqi/authssl.cc | 10 +++++----- libretroshare/src/pqi/pqibin.cc | 4 ++-- libretroshare/src/pqi/pqistore.cc | 4 ++-- libretroshare/src/pqi/pqistreamer.cc | 4 ++-- libretroshare/src/serialiser/rsserial.h | 2 +- libretroshare/src/serialiser/rstlvbinary.cc | 2 +- libretroshare/src/services/p3gxschannels.cc | 6 ++++++ libretroshare/src/services/p3gxscommon.cc | 2 +- libretroshare/src/services/p3photoservice.cc | 2 +- libretroshare/src/tcponudp/tcppacket.cc | 13 ++++++++++--- libretroshare/src/tcponudp/udprelay.cc | 2 +- libretroshare/src/tcponudp/udpstunner.cc | 2 +- libretroshare/src/turtle/rsturtleitem.cc | 2 +- libretroshare/src/util/rscompress.cc | 4 ++-- libretroshare/src/util/rsmemory.cc | 2 +- libretroshare/src/util/rsmemory.h | 4 ++-- libretroshare/src/util/smallobject.cc | 2 +- plugins/VOIP/gui/SpeexProcessor.cpp | 2 +- plugins/VOIP/gui/VideoProcessor.cpp | 4 ++-- plugins/VOIP/services/p3VOIP.cc | 4 ++-- plugins/VOIP/services/rsVOIPItems.cc | 2 +- retroshare-gui/src/gui/common/RSTextBrowser.cpp | 4 ++++ retroshare-gui/src/gui/notifyqt.cpp | 4 ++-- 35 files changed, 73 insertions(+), 56 deletions(-) diff --git a/libretroshare/src/dbase/fimonitor.cc b/libretroshare/src/dbase/fimonitor.cc index 69ae9b109..c4f60ee81 100644 --- a/libretroshare/src/dbase/fimonitor.cc +++ b/libretroshare/src/dbase/fimonitor.cc @@ -129,7 +129,7 @@ HashCache::HashCache(const std::string& path) // read the binary stream into memory. // - void *buffer = rs_safe_malloc(file_size) ; + void *buffer = rs_malloc(file_size) ; if(buffer == NULL) return ; diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index 259ec8889..fc66c7f2a 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -748,7 +748,7 @@ bool ftController::copyFile(const std::string& source,const std::string& dest) size_t T=0; static const int BUFF_SIZE = 10485760 ; // 10 MB buffer to speed things up. - void *buffer = rs_safe_malloc(BUFF_SIZE) ; + void *buffer = rs_malloc(BUFF_SIZE) ; if(buffer == NULL) { diff --git a/libretroshare/src/ft/ftdatamultiplex.cc b/libretroshare/src/ft/ftdatamultiplex.cc index 1574f9519..a30545b38 100644 --- a/libretroshare/src/ft/ftdatamultiplex.cc +++ b/libretroshare/src/ft/ftdatamultiplex.cc @@ -879,7 +879,7 @@ bool ftDataMultiplex::locked_handleServerRequest(ftFileProvider *provider, const std::cerr << "Warning: peer " << peerId << " is asking a large chunk (s=" << chunksize << ") for hash " << hash << ", filesize=" << size << ". This is unexpected." << std::endl ; return false ; } - void *data = rs_safe_malloc(chunksize); + void *data = rs_malloc(chunksize); if(data == NULL) return false ; diff --git a/libretroshare/src/ft/ftserver.cc b/libretroshare/src/ft/ftserver.cc index 5cfae3909..2bcb53a5f 100644 --- a/libretroshare/src/ft/ftserver.cc +++ b/libretroshare/src/ft/ftserver.cc @@ -1102,7 +1102,7 @@ bool ftServer::sendData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t item->chunk_offset = offset+baseoffset ; item->chunk_size = chunk; - item->chunk_data = rs_safe_malloc(chunk) ; + item->chunk_data = rs_malloc(chunk) ; if(item->chunk_data == NULL) { diff --git a/libretroshare/src/ft/ftturtlefiletransferitem.cc b/libretroshare/src/ft/ftturtlefiletransferitem.cc index 463058798..4ec1123cc 100644 --- a/libretroshare/src/ft/ftturtlefiletransferitem.cc +++ b/libretroshare/src/ft/ftturtlefiletransferitem.cc @@ -436,7 +436,7 @@ RsTurtleFileDataItem::RsTurtleFileDataItem(void *data,uint32_t pktsize) if(chunk_size > rssize || rssize - chunk_size < offset) throw std::runtime_error("RsTurtleFileDataItem::() error while deserializing.") ; - chunk_data = (void*)rs_safe_malloc(chunk_size) ; + chunk_data = (void*)rs_malloc(chunk_size) ; if(chunk_data == NULL) throw std::runtime_error("RsTurtleFileDataItem::() cannot allocate memory.") ; diff --git a/libretroshare/src/grouter/grouteritems.cc b/libretroshare/src/grouter/grouteritems.cc index 27120167a..aa077b590 100644 --- a/libretroshare/src/grouter/grouteritems.cc +++ b/libretroshare/src/grouter/grouteritems.cc @@ -86,7 +86,7 @@ RsGRouterTransactionChunkItem *RsGRouterSerialiser::deserialise_RsGRouterTransac delete item; return NULL ; } - if( NULL == (item->chunk_data = (uint8_t*)rs_safe_malloc(item->chunk_size))) + if( NULL == (item->chunk_data = (uint8_t*)rs_malloc(item->chunk_size))) { delete item; return NULL ; @@ -149,7 +149,7 @@ RsGRouterGenericDataItem *RsGRouterSerialiser::deserialise_RsGRouterGenericDataI return NULL ; } - if( NULL == (item->data_bytes = (uint8_t*)rs_safe_malloc(item->data_size))) + if( NULL == (item->data_bytes = (uint8_t*)rs_malloc(item->data_size))) { delete item; return NULL ; @@ -346,7 +346,7 @@ RsGRouterGenericDataItem *RsGRouterGenericDataItem::duplicate() const // then duplicate the memory chunk - item->data_bytes = (uint8_t*)rs_safe_malloc(data_size) ; + item->data_bytes = (uint8_t*)rs_malloc(data_size) ; if(item->data_bytes == NULL) return NULL ; diff --git a/libretroshare/src/grouter/grouteritems.h b/libretroshare/src/grouter/grouteritems.h index 9da6d104b..ad87d1051 100644 --- a/libretroshare/src/grouter/grouteritems.h +++ b/libretroshare/src/grouter/grouteritems.h @@ -196,7 +196,7 @@ class RsGRouterTransactionChunkItem: public RsGRouterTransactionItem, public RsG { RsGRouterTransactionChunkItem *item = new RsGRouterTransactionChunkItem ; *item = *this ; // copy all fields - item->chunk_data = (uint8_t*)rs_safe_malloc(chunk_size) ; // deep copy memory chunk + item->chunk_data = (uint8_t*)rs_malloc(chunk_size) ; // deep copy memory chunk if(item->chunk_data == NULL) return NULL ; diff --git a/libretroshare/src/grouter/p3grouter.cc b/libretroshare/src/grouter/p3grouter.cc index 65293b4a7..e11358970 100644 --- a/libretroshare/src/grouter/p3grouter.cc +++ b/libretroshare/src/grouter/p3grouter.cc @@ -1121,7 +1121,7 @@ bool p3GRouter::locked_sendTransactionData(const RsPeerId& pid,const RsGRouterTr std::cerr << " sending to tunnel vpid " << pid << std::endl; #endif uint32_t turtle_data_size = trans_item.serial_size() ; - uint8_t *turtle_data = (uint8_t*)rs_safe_malloc(turtle_data_size) ; + uint8_t *turtle_data = (uint8_t*)rs_malloc(turtle_data_size) ; if(turtle_data == NULL) return false ; @@ -1302,7 +1302,7 @@ bool p3GRouter::sliceDataItem(RsGRouterAbstractMsgItem *item,std::listtotal_size = size; chunk_item->chunk_start= offset; chunk_item->chunk_size = chunk_size ; - chunk_item->chunk_data = (uint8_t*)rs_safe_malloc(chunk_size) ; + chunk_item->chunk_data = (uint8_t*)rs_malloc(chunk_size) ; #ifdef GROUTER_DEBUG std::cerr << " preparing to send a chunk [" << offset << " -> " << offset + chunk_size << " / " << size << "]" << std::endl; #endif @@ -1918,7 +1918,7 @@ bool p3GRouter::sendData(const RsGxsId& destination,const GRouterServiceId& clie RsGRouterGenericDataItem *data_item = new RsGRouterGenericDataItem ; - data_item->data_bytes = (uint8_t*)rs_safe_malloc(data_size) ; + data_item->data_bytes = (uint8_t*)rs_malloc(data_size) ; if(data_item->data_bytes == NULL) return false ; diff --git a/libretroshare/src/gxs/gxssecurity.cc b/libretroshare/src/gxs/gxssecurity.cc index b310b6b64..8b27fe1bc 100644 --- a/libretroshare/src/gxs/gxssecurity.cc +++ b/libretroshare/src/gxs/gxssecurity.cc @@ -444,7 +444,7 @@ bool GxsSecurity::encrypt(uint8_t *& out, uint32_t &outlen, const uint8_t *in, u int out_offset = 0; int max_evp_key_size = EVP_PKEY_size(public_key); - ek = (unsigned char*)rs_safe_malloc(max_evp_key_size); + ek = (unsigned char*)rs_malloc(max_evp_key_size); if(ek == NULL) return false ; @@ -459,7 +459,7 @@ bool GxsSecurity::encrypt(uint8_t *& out, uint32_t &outlen, const uint8_t *in, u if(!EVP_SealInit(&ctx, EVP_aes_128_cbc(), &ek, &eklen, iv, &public_key, 1)) return false; // now assign memory to out accounting for data, and cipher block size, key length, and key length val - out = (uint8_t*)rs_safe_malloc(inlen + cipher_block_size + size_net_ekl + eklen + EVP_MAX_IV_LENGTH); + out = (uint8_t*)rs_malloc(inlen + cipher_block_size + size_net_ekl + eklen + EVP_MAX_IV_LENGTH); if(out == NULL) return false ; @@ -541,7 +541,7 @@ bool GxsSecurity::decrypt(uint8_t *& out, uint32_t & outlen, const uint8_t *in, EVP_CIPHER_CTX ctx; int eklen = 0, net_ekl = 0; - unsigned char *ek = (unsigned char*)rs_safe_malloc(EVP_PKEY_size(privateKey)); + unsigned char *ek = (unsigned char*)rs_malloc(EVP_PKEY_size(privateKey)); if(ek == NULL) return false ; @@ -579,7 +579,7 @@ bool GxsSecurity::decrypt(uint8_t *& out, uint32_t & outlen, const uint8_t *in, std::cerr << "Severe error in " << __PRETTY_FUNCTION__ << ": cannot encrypt. " << std::endl; return false ; } - out = (uint8_t*)rs_safe_malloc(inlen - in_offset); + out = (uint8_t*)rs_malloc(inlen - in_offset); if(out == NULL) return false; diff --git a/libretroshare/src/gxstunnel/p3gxstunnel.cc b/libretroshare/src/gxstunnel/p3gxstunnel.cc index bc858b5bf..43ff5b0b3 100644 --- a/libretroshare/src/gxstunnel/p3gxstunnel.cc +++ b/libretroshare/src/gxstunnel/p3gxstunnel.cc @@ -1141,7 +1141,7 @@ bool p3GxsTunnelService::locked_sendClearTunnelData(RsGxsTunnelDHPublicKeyItem * uint32_t rssize = item->serial_size() ; gitem->data_size = rssize + 8 ; - gitem->data_bytes = rs_safe_malloc(rssize+8) ; + gitem->data_bytes = rs_malloc(rssize+8) ; if(gitem->data_bytes == NULL) { @@ -1231,7 +1231,7 @@ bool p3GxsTunnelService::locked_sendEncryptedTunnelData(RsGxsTunnelItem *item) RsTurtleGenericDataItem *gitem = new RsTurtleGenericDataItem ; gitem->data_size = encrypted_size + GXS_TUNNEL_ENCRYPTION_IV_SIZE + GXS_TUNNEL_ENCRYPTION_HMAC_SIZE ; - gitem->data_bytes = rs_safe_malloc(gitem->data_size) ; + gitem->data_bytes = rs_malloc(gitem->data_size) ; if(gitem->data_bytes == NULL) return false ; @@ -1329,7 +1329,7 @@ bool p3GxsTunnelService::sendData(const RsGxsTunnelId &tunnel_id, uint32_t servi item->flags = 0; // not used yet. item->service_id = service_id; item->data_size = size; // encrypted data size - item->data = (uint8_t*)rs_safe_malloc(size); // encrypted data + item->data = (uint8_t*)rs_malloc(size); // encrypted data if(item->data == NULL) delete item ; diff --git a/libretroshare/src/gxstunnel/rsgxstunnelitems.cc b/libretroshare/src/gxstunnel/rsgxstunnelitems.cc index 37c03a237..8898a352a 100644 --- a/libretroshare/src/gxstunnel/rsgxstunnelitems.cc +++ b/libretroshare/src/gxstunnel/rsgxstunnelitems.cc @@ -394,7 +394,7 @@ RsGxsTunnelDataItem *RsGxsTunnelSerialiser::deserialise_RsGxsTunnelDataItem(void delete item ; return NULL ; } - item->data = (unsigned char*)rs_safe_malloc(item->data_size) ; + item->data = (unsigned char*)rs_malloc(item->data_size) ; if(item->data == NULL) { diff --git a/libretroshare/src/pgp/pgphandler.cc b/libretroshare/src/pgp/pgphandler.cc index 1c7fa311d..22ce28a48 100644 --- a/libretroshare/src/pgp/pgphandler.cc +++ b/libretroshare/src/pgp/pgphandler.cc @@ -40,7 +40,7 @@ PassphraseCallback PGPHandler::_passphrase_callback = NULL ; ops_keyring_t *PGPHandler::allocateOPSKeyring() { - ops_keyring_t *kr = (ops_keyring_t*)rs_safe_malloc(sizeof(ops_keyring_t)) ; + ops_keyring_t *kr = (ops_keyring_t*)rs_malloc(sizeof(ops_keyring_t)) ; if(kr == NULL) return NULL ; diff --git a/libretroshare/src/pqi/authssl.cc b/libretroshare/src/pqi/authssl.cc index cfdae9e61..f03847883 100644 --- a/libretroshare/src/pqi/authssl.cc +++ b/libretroshare/src/pqi/authssl.cc @@ -117,7 +117,7 @@ static struct CRYPTO_dynlock_value *dyn_create_function(const char */*file*/, in { struct CRYPTO_dynlock_value *value; - value = (struct CRYPTO_dynlock_value*) rs_safe_malloc(sizeof(struct CRYPTO_dynlock_value)); + value = (struct CRYPTO_dynlock_value*) rs_malloc(sizeof(struct CRYPTO_dynlock_value)); if (!value) return NULL; @@ -166,7 +166,7 @@ static void dyn_destroy_function(struct CRYPTO_dynlock_value *l, const char */*f bool tls_init() { /* static locks area */ - mutex_buf = (pthread_mutex_t*) rs_safe_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)); + mutex_buf = (pthread_mutex_t*) rs_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)); if (mutex_buf == NULL) return false; @@ -1259,7 +1259,7 @@ bool AuthSSLimpl::encrypt(void *&out, int &outlen, const void *in, int inlen, int out_offset = 0; int max_evp_key_size = EVP_PKEY_size(public_key); - ek = (unsigned char*)rs_safe_malloc(max_evp_key_size); + ek = (unsigned char*)rs_malloc(max_evp_key_size); if(ek == NULL) return false ; @@ -1277,7 +1277,7 @@ bool AuthSSLimpl::encrypt(void *&out, int &outlen, const void *in, int inlen, } // now assign memory to out accounting for data, and cipher block size, key length, and key length val - out = (unsigned char*)rs_safe_malloc(inlen + cipher_block_size + size_net_ekl + eklen + EVP_MAX_IV_LENGTH); + out = (unsigned char*)rs_malloc(inlen + cipher_block_size + size_net_ekl + eklen + EVP_MAX_IV_LENGTH); if(out == NULL) { @@ -1395,7 +1395,7 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen) return false; } - out = (unsigned char*)rs_safe_malloc(inlen - in_offset); + out = (unsigned char*)rs_malloc(inlen - in_offset); if(out == NULL) { diff --git a/libretroshare/src/pqi/pqibin.cc b/libretroshare/src/pqi/pqibin.cc index a07303cb0..dcc89b525 100644 --- a/libretroshare/src/pqi/pqibin.cc +++ b/libretroshare/src/pqi/pqibin.cc @@ -315,7 +315,7 @@ BinMemInterface::BinMemInterface(int defsize, int flags) :bin_flags(flags), buf(NULL), size(defsize), recvsize(0), readloc(0), hash(NULL), bcount(0) { - buf = rs_safe_malloc(defsize); + buf = rs_malloc(defsize); if(buf == NULL) { @@ -333,7 +333,7 @@ BinMemInterface::BinMemInterface(const void *data, const int defsize, int flags) :bin_flags(flags), buf(NULL), size(defsize), recvsize(0), readloc(0), hash(NULL), bcount(0) { - buf = rs_safe_malloc(defsize); + buf = rs_malloc(defsize); if(buf == NULL) { diff --git a/libretroshare/src/pqi/pqistore.cc b/libretroshare/src/pqi/pqistore.cc index 7b364e663..6dedbd5fc 100644 --- a/libretroshare/src/pqi/pqistore.cc +++ b/libretroshare/src/pqi/pqistore.cc @@ -289,7 +289,7 @@ int pqistore::readPkt(RsItem **item_out) // initial read size: basic packet. int blen = getRsPktBaseSize(); - void *block = rs_safe_malloc(blen); + void *block = rs_malloc(blen); if(block == NULL) return false ; @@ -499,7 +499,7 @@ int pqiSSLstore::readPkt(RsItem **item_out) // initial read size: basic packet. int blen = getRsPktBaseSize(); - void *block = rs_safe_malloc(blen); + void *block = rs_malloc(blen); if(block == NULL) return false ; diff --git a/libretroshare/src/pqi/pqistreamer.cc b/libretroshare/src/pqi/pqistreamer.cc index 29fea90db..640a20638 100644 --- a/libretroshare/src/pqi/pqistreamer.cc +++ b/libretroshare/src/pqi/pqistreamer.cc @@ -315,7 +315,7 @@ int pqistreamer::queue_outpqi_locked(RsItem *pqi,uint32_t& pktsize) /* decide which type of packet it is */ pktsize = mRsSerialiser->size(pqi); - void *ptr = rs_safe_malloc(pktsize); + void *ptr = rs_malloc(pktsize); if(ptr == NULL) return 0 ; @@ -1044,7 +1044,7 @@ void pqistreamer::allocate_rpend_locked() return; mPkt_rpend_size = getRsPktMaxSize(); - mPkt_rpending = rs_safe_malloc(mPkt_rpend_size); + mPkt_rpending = rs_malloc(mPkt_rpend_size); if(mPkt_rpending == NULL) return ; diff --git a/libretroshare/src/serialiser/rsserial.h b/libretroshare/src/serialiser/rsserial.h index ee91394b0..47b0666fc 100644 --- a/libretroshare/src/serialiser/rsserial.h +++ b/libretroshare/src/serialiser/rsserial.h @@ -182,7 +182,7 @@ class RsRawItem: public RsItem RsRawItem(uint32_t t, uint32_t size) :RsItem(t), len(size) { - data = rs_safe_malloc(len); + data = rs_malloc(len); } virtual ~RsRawItem() diff --git a/libretroshare/src/serialiser/rstlvbinary.cc b/libretroshare/src/serialiser/rstlvbinary.cc index 0ce41df26..672f6c54b 100644 --- a/libretroshare/src/serialiser/rstlvbinary.cc +++ b/libretroshare/src/serialiser/rstlvbinary.cc @@ -75,7 +75,7 @@ bool RsTlvBinaryData::setBinData(const void *data, uint32_t size) return true; } - bin_data = rs_safe_malloc(bin_len); + bin_data = rs_malloc(bin_len); if(bin_data == NULL) return false ; diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index d25220662..a8b7224ef 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -916,6 +916,12 @@ bool SSGxsChannelGroup::load(const std::string &input) mAutoDownload = false; mDownloadDirectory.clear(); + if(input.empty()) + { + std::cerr << "(EE) SSGxsChannelGroup::load() asked to load a null string. Weird." << std::endl; + return false ; + } + RsTemporaryMemory tmpmem(input.length()); if (1 == sscanf(input.c_str(), "D:%d", &download_val)) diff --git a/libretroshare/src/services/p3gxscommon.cc b/libretroshare/src/services/p3gxscommon.cc index 25f348c2c..ad97f1eca 100644 --- a/libretroshare/src/services/p3gxscommon.cc +++ b/libretroshare/src/services/p3gxscommon.cc @@ -98,7 +98,7 @@ void RsGxsImage::take(uint8_t *data, uint32_t size) // NB Must make sure that we always use malloc/free for this data. uint8_t *RsGxsImage::allocate(uint32_t size) { - uint8_t *val = (uint8_t *) rs_safe_malloc(size); + uint8_t *val = (uint8_t *) rs_malloc(size); #ifdef DEBUG_GXSCOMMON std::cerr << "RsGxsImage()::allocate(" << (void *) val << ")"; diff --git a/libretroshare/src/services/p3photoservice.cc b/libretroshare/src/services/p3photoservice.cc index f002290aa..759f5ad18 100644 --- a/libretroshare/src/services/p3photoservice.cc +++ b/libretroshare/src/services/p3photoservice.cc @@ -26,7 +26,7 @@ bool RsPhotoThumbnail::copyFrom(const RsPhotoThumbnail &nail) size = nail.size; type = nail.type; - data = (uint8_t *) rs_safe_malloc(size); + data = (uint8_t *) rs_malloc(size); if(data == NULL) return false ; diff --git a/libretroshare/src/tcponudp/tcppacket.cc b/libretroshare/src/tcponudp/tcppacket.cc index fee71e1bc..3f308de1a 100644 --- a/libretroshare/src/tcponudp/tcppacket.cc +++ b/libretroshare/src/tcponudp/tcppacket.cc @@ -80,7 +80,7 @@ TcpPacket::TcpPacket(uint8 *ptr, int size) if (size > 0) { datasize = size; - data = (uint8 *) rs_safe_malloc(datasize); + data = (uint8 *) rs_malloc(datasize); if(data != NULL) memcpy(data, (void *) ptr, size); @@ -188,10 +188,17 @@ int TcpPacket::readPacket(void *buf, int size) free(data); } datasize = size - TCP_PSEUDO_HDR_SIZE; - data = (uint8 *) rs_safe_malloc(datasize); - if(data == NULL) + if(datasize == 0) // this happens! + { + data = NULL ; return 0 ; + } + + data = (uint8 *) rs_malloc(datasize); + + if(data == NULL) + return 0 ; /* now the data */ memcpy(data, (void *) &(((uint8 *) buf)[20]), datasize); diff --git a/libretroshare/src/tcponudp/udprelay.cc b/libretroshare/src/tcponudp/udprelay.cc index 7ca78b69c..2f837feec 100644 --- a/libretroshare/src/tcponudp/udprelay.cc +++ b/libretroshare/src/tcponudp/udprelay.cc @@ -71,7 +71,7 @@ UdpRelayReceiver::UdpRelayReceiver(UdpPublisher *pub) setRelayClassMax(UDP_RELAY_CLASS_GENERAL, UDP_RELAY_DEFAULT_GENERAL, UDP_RELAY_DEFAULT_BANDWIDTH); /* only allocate this space once */ - mTmpSendPkt = rs_safe_malloc(MAX_RELAY_UDP_PACKET_SIZE); + mTmpSendPkt = rs_malloc(MAX_RELAY_UDP_PACKET_SIZE); mTmpSendSize = MAX_RELAY_UDP_PACKET_SIZE; clearDataTransferred(); diff --git a/libretroshare/src/tcponudp/udpstunner.cc b/libretroshare/src/tcponudp/udpstunner.cc index 9add379ed..421ad8f17 100644 --- a/libretroshare/src/tcponudp/udpstunner.cc +++ b/libretroshare/src/tcponudp/udpstunner.cc @@ -536,7 +536,7 @@ bool UdpStun_generate_stun_pkt(void *stun_pkt, int *len) void *UdpStun_generate_stun_reply(struct sockaddr_in *stun_addr, int *len) { /* just the header */ - void *stun_pkt = rs_safe_malloc(28); + void *stun_pkt = rs_malloc(28); if(!stun_pkt) return NULL ; diff --git a/libretroshare/src/turtle/rsturtleitem.cc b/libretroshare/src/turtle/rsturtleitem.cc index 6cae770d7..4c469196e 100644 --- a/libretroshare/src/turtle/rsturtleitem.cc +++ b/libretroshare/src/turtle/rsturtleitem.cc @@ -547,7 +547,7 @@ RsTurtleGenericDataItem::RsTurtleGenericDataItem(void *data,uint32_t pktsize) if(data_size > rssize || rssize - data_size < offset) throw std::runtime_error("RsTurtleTunnelOkItem::() wrong data_size (exceeds rssize).") ; - data_bytes = rs_safe_malloc(data_size) ; + data_bytes = rs_malloc(data_size) ; if(data_bytes != NULL) { diff --git a/libretroshare/src/util/rscompress.cc b/libretroshare/src/util/rscompress.cc index d8a7a778a..42b077e1c 100644 --- a/libretroshare/src/util/rscompress.cc +++ b/libretroshare/src/util/rscompress.cc @@ -43,7 +43,7 @@ bool RsCompress::compress_memory_chunk(const uint8_t *input_mem,const uint32_t i uint32_t output_offset = 0 ; uint32_t input_offset = 0 ; output_size = 1024 ; - output_mem = (uint8_t*)rs_safe_malloc(output_size) ; + output_mem = (uint8_t*)rs_malloc(output_size) ; if(!output_mem) return false ; @@ -117,7 +117,7 @@ bool RsCompress::uncompress_memory_chunk(const uint8_t *input_mem,const uint32_t output_size = input_size ; uint32_t output_offset = 0 ; uint32_t input_offset = 0 ; - output_mem = (uint8_t*)rs_safe_malloc(output_size) ; + output_mem = (uint8_t*)rs_malloc(output_size) ; if(!output_mem) return false ; diff --git a/libretroshare/src/util/rsmemory.cc b/libretroshare/src/util/rsmemory.cc index 0d68bbad4..46ffd4a58 100644 --- a/libretroshare/src/util/rsmemory.cc +++ b/libretroshare/src/util/rsmemory.cc @@ -1,6 +1,6 @@ #include "util/rsmemory.h" -void *rs_safe_malloc(size_t size) +void *rs_malloc(size_t size) { static const size_t SAFE_MEMALLOC_THRESHOLD = 1024*1024*1024 ; // 1Gb should be enough for everything! diff --git a/libretroshare/src/util/rsmemory.h b/libretroshare/src/util/rsmemory.h index e12a5bc5a..7da4245c4 100644 --- a/libretroshare/src/util/rsmemory.h +++ b/libretroshare/src/util/rsmemory.h @@ -4,7 +4,7 @@ #include #include -void *rs_safe_malloc(size_t size) ; +void *rs_malloc(size_t size) ; // This is a scope guard to release the memory block when going of of the current scope. // Can be very useful to auto-delete some memory on quit without the need to call free each time. @@ -28,7 +28,7 @@ class RsTemporaryMemory public: RsTemporaryMemory(size_t s) { - _mem = (unsigned char *)rs_safe_malloc(s) ; + _mem = (unsigned char *)rs_malloc(s) ; if(_mem) _size = s ; diff --git a/libretroshare/src/util/smallobject.cc b/libretroshare/src/util/smallobject.cc index e075b4821..ff9beeb48 100644 --- a/libretroshare/src/util/smallobject.cc +++ b/libretroshare/src/util/smallobject.cc @@ -207,7 +207,7 @@ SmallObjectAllocator::~SmallObjectAllocator() void *SmallObjectAllocator::allocate(size_t bytes) { if(bytes > _maxObjectSize) - return rs_safe_malloc(bytes) ; + return rs_malloc(bytes) ; else if(_lastAlloc != NULL && _lastAlloc->blockSize() == bytes) return _lastAlloc->allocate() ; else diff --git a/plugins/VOIP/gui/SpeexProcessor.cpp b/plugins/VOIP/gui/SpeexProcessor.cpp index 078fbacba..1ff7bab17 100644 --- a/plugins/VOIP/gui/SpeexProcessor.cpp +++ b/plugins/VOIP/gui/SpeexProcessor.cpp @@ -351,7 +351,7 @@ void SpeexOutputProcessor::putNetworkPacket(QString name, QByteArray packet) { if (userJitterHash.contains(name)) { userJitter = userJitterHash.value(name); } else { - userJitter = (SpeexJitter*)rs_safe_malloc(sizeof(SpeexJitter)); + userJitter = (SpeexJitter*)rs_malloc(sizeof(SpeexJitter)); if(!userJitter) return ; diff --git a/plugins/VOIP/gui/VideoProcessor.cpp b/plugins/VOIP/gui/VideoProcessor.cpp index 7ecd380ea..5f4d5de0e 100644 --- a/plugins/VOIP/gui/VideoProcessor.cpp +++ b/plugins/VOIP/gui/VideoProcessor.cpp @@ -386,7 +386,7 @@ bool JPEGVideo::encodeData(const QImage& image,uint32_t /* size_hint */,RsVOIPDa buffer.open(QIODevice::WriteOnly) ; encoded_frame.save(&buffer,"JPEG") ; - voip_chunk.data = rs_safe_malloc(HEADER_SIZE + qb.size()); + voip_chunk.data = rs_malloc(HEADER_SIZE + qb.size()); if(!voip_chunk.data) return false ; @@ -684,7 +684,7 @@ bool FFmpegVideo::encodeData(const QImage& image, uint32_t target_encoding_bitra if(got_output) { - voip_chunk.data = rs_safe_malloc(pkt.size + HEADER_SIZE) ; + voip_chunk.data = rs_malloc(pkt.size + HEADER_SIZE) ; if(!voip_chunk.data) return false ; diff --git a/plugins/VOIP/services/p3VOIP.cc b/plugins/VOIP/services/p3VOIP.cc index 421a727f5..859c5bf35 100644 --- a/plugins/VOIP/services/p3VOIP.cc +++ b/plugins/VOIP/services/p3VOIP.cc @@ -280,7 +280,7 @@ int p3VOIP::sendVoipData(const RsPeerId& peer_id,const RsVOIPDataChunk& chunk) std::cerr << "Cannot allocate RsVOIPDataItem !" << std::endl; return false ; } - item->voip_data = rs_safe_malloc(chunk.size) ; + item->voip_data = rs_malloc(chunk.size) ; if(item->voip_data == NULL) { @@ -431,7 +431,7 @@ bool p3VOIP::getIncomingData(const RsPeerId& peer_id,std::vectordata_size ; - chunk.data = rs_safe_malloc((*it2)->data_size) ; + chunk.data = rs_malloc((*it2)->data_size) ; if(chunk.data == NULL) { diff --git a/plugins/VOIP/services/rsVOIPItems.cc b/plugins/VOIP/services/rsVOIPItems.cc index 1beab94b7..cd3132dfd 100644 --- a/plugins/VOIP/services/rsVOIPItems.cc +++ b/plugins/VOIP/services/rsVOIPItems.cc @@ -450,7 +450,7 @@ RsVOIPDataItem::RsVOIPDataItem(void *data, uint32_t pktsize) if(data_size > rssize || rssize - data_size < offset) throw std::runtime_error("Not enough space.") ; - voip_data = rs_safe_malloc(data_size) ; + voip_data = rs_malloc(data_size) ; if(!voip_data) throw std::runtime_error("Serialization error.") ; diff --git a/retroshare-gui/src/gui/common/RSTextBrowser.cpp b/retroshare-gui/src/gui/common/RSTextBrowser.cpp index 930c506ac..0954967bc 100644 --- a/retroshare-gui/src/gui/common/RSTextBrowser.cpp +++ b/retroshare-gui/src/gui/common/RSTextBrowser.cpp @@ -1,3 +1,5 @@ +#include + #include #include @@ -72,6 +74,8 @@ void RSTextBrowser::paintEvent(QPaintEvent *event) QVariant RSTextBrowser::loadResource(int type, const QUrl &name) { + std::cerr << "TEXTBROWSER loading ressource: type=" << type << " url=" << name.toString().toStdString() << std::endl; + if (mShowImages || type != QTextDocument::ImageResource || name.scheme().compare("data", Qt::CaseInsensitive) != 0) { return QTextBrowser::loadResource(type, name); } diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 1cbff3dcc..883c05e28 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -151,7 +151,7 @@ class SignatureEventData { // We need a new memory chnk because there's no guarranty _sign nor _signlen are not in the stack - sign = (unsigned char *)rs_safe_malloc(_signlen) ; + sign = (unsigned char *)rs_malloc(_signlen) ; if(!sign) { @@ -163,7 +163,7 @@ class SignatureEventData signlen = new unsigned int ; *signlen = _signlen ; signature_result = SELF_SIGNATURE_RESULT_PENDING ; - data = rs_safe_malloc(_len) ; + data = rs_malloc(_len) ; if(!data) {