mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Memory leaks:
- ftController::copyFile -> buffer and file pointer leaks in case of error - PeersDialog::insertSendList -> new QTreeWidgetItem for all online peers, this function is not ready yet - PeersDialog::insertPeers -> gpg_item = new QTreeWidgetItem(0); in case of no more accept connection - pqissl::reset -> missing SSL_free of ssl_connection Missing return: - IntroPage::nextId git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2891 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
faace1f322
commit
b242b73f31
@ -629,8 +629,6 @@ bool ftController::copyFile(const std::string& source,const std::string& dest)
|
|||||||
{
|
{
|
||||||
std::string error ;
|
std::string error ;
|
||||||
|
|
||||||
static const int BUFF_SIZE = 10485760 ; // 10 MB buffer to speed things up.
|
|
||||||
void *buffer = malloc(BUFF_SIZE) ;
|
|
||||||
FILE *in = fopen(source.c_str(),"rb") ;
|
FILE *in = fopen(source.c_str(),"rb") ;
|
||||||
|
|
||||||
if(in == NULL)
|
if(in == NULL)
|
||||||
@ -644,12 +642,18 @@ bool ftController::copyFile(const std::string& source,const std::string& dest)
|
|||||||
if(out == NULL)
|
if(out == NULL)
|
||||||
{
|
{
|
||||||
getPqiNotify()->AddSysMessage(0, RS_SYS_WARNING, "File copy error", "Error while copying file " + dest + "\nCheck for disk full, or write permission ?\nOriginal file kept under the name "+source);
|
getPqiNotify()->AddSysMessage(0, RS_SYS_WARNING, "File copy error", "Error while copying file " + dest + "\nCheck for disk full, or write permission ?\nOriginal file kept under the name "+source);
|
||||||
|
fclose (in);
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t s=0;
|
size_t s=0;
|
||||||
size_t T=0;
|
size_t T=0;
|
||||||
|
|
||||||
|
static const int BUFF_SIZE = 10485760 ; // 10 MB buffer to speed things up.
|
||||||
|
void *buffer = malloc(BUFF_SIZE) ;
|
||||||
|
|
||||||
|
bool bRet = true;
|
||||||
|
|
||||||
while( (s = fread(buffer,1,BUFF_SIZE,in)) > 0)
|
while( (s = fread(buffer,1,BUFF_SIZE,in)) > 0)
|
||||||
{
|
{
|
||||||
size_t t = fwrite(buffer,1,s,out) ;
|
size_t t = fwrite(buffer,1,s,out) ;
|
||||||
@ -658,7 +662,8 @@ bool ftController::copyFile(const std::string& source,const std::string& dest)
|
|||||||
if(t != s)
|
if(t != s)
|
||||||
{
|
{
|
||||||
getPqiNotify()->AddSysMessage(0, RS_SYS_WARNING, "File copy error", "Error while copying file " + dest + "\nIs your disc full ?\nOriginal file kept under the name "+source);
|
getPqiNotify()->AddSysMessage(0, RS_SYS_WARNING, "File copy error", "Error while copying file " + dest + "\nIs your disc full ?\nOriginal file kept under the name "+source);
|
||||||
return false ;
|
bRet = false ;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,6 +224,7 @@ int pqissl::reset()
|
|||||||
active = false;
|
active = false;
|
||||||
sockfd = -1;
|
sockfd = -1;
|
||||||
waiting = WAITING_NOT;
|
waiting = WAITING_NOT;
|
||||||
|
SSL_free (ssl_connection);
|
||||||
ssl_connection = NULL;
|
ssl_connection = NULL;
|
||||||
sameLAN = false;
|
sameLAN = false;
|
||||||
n_read_zero = 0;
|
n_read_zero = 0;
|
||||||
|
@ -430,23 +430,27 @@ void PeersDialog::insertPeers()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* make a widget per friend */
|
/* make a widget per friend */
|
||||||
QTreeWidgetItem *gpg_item;
|
QTreeWidgetItem *gpg_item = NULL;
|
||||||
QList<QTreeWidgetItem *> list = peertreeWidget->findItems(QString::fromStdString(*it), Qt::MatchExactly, 3);
|
QList<QTreeWidgetItem *> list = peertreeWidget->findItems(QString::fromStdString(*it), Qt::MatchExactly, 3);
|
||||||
if (list.size() == 1) {
|
if (list.size() > 0) {
|
||||||
gpg_item = list.front();
|
gpg_item = list.front();
|
||||||
} else {
|
|
||||||
gpg_item = new QTreeWidgetItem(0); //set type to 0 for custom popup menu
|
|
||||||
gpg_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RsPeerDetails detail;
|
RsPeerDetails detail;
|
||||||
if ((!rsPeers->getPeerDetails(*it, detail) || !detail.accept_connection)
|
if ((!rsPeers->getPeerDetails(*it, detail) || !detail.accept_connection)
|
||||||
&& detail.gpg_id != rsPeers->getGPGOwnId()) {
|
&& detail.gpg_id != rsPeers->getGPGOwnId()) {
|
||||||
//don't accept anymore connection, remove from the view
|
//don't accept anymore connection, remove from the view
|
||||||
delete (peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(gpg_item)));
|
if (gpg_item) {
|
||||||
|
delete (peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(gpg_item)));
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gpg_item == NULL) {
|
||||||
|
gpg_item = new QTreeWidgetItem(0); //set type to 0 for custom popup menu
|
||||||
|
gpg_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||||
|
}
|
||||||
|
|
||||||
//use to mark item as updated
|
//use to mark item as updated
|
||||||
gpg_item->setData(0, Qt::UserRole, true);
|
gpg_item->setData(0, Qt::UserRole, true);
|
||||||
gpg_item -> setText(0, QString::fromStdString(detail.name));
|
gpg_item -> setText(0, QString::fromStdString(detail.name));
|
||||||
@ -475,7 +479,7 @@ void PeersDialog::insertPeers()
|
|||||||
std::list<std::string> sslContacts;
|
std::list<std::string> sslContacts;
|
||||||
rsPeers->getSSLChildListOfGPGId(detail.gpg_id, sslContacts);
|
rsPeers->getSSLChildListOfGPGId(detail.gpg_id, sslContacts);
|
||||||
for(std::list<std::string>::iterator sslIt = sslContacts.begin(); sslIt != sslContacts.end(); sslIt++) {
|
for(std::list<std::string>::iterator sslIt = sslContacts.begin(); sslIt != sslContacts.end(); sslIt++) {
|
||||||
QTreeWidgetItem *sslItem;
|
QTreeWidgetItem *sslItem = NULL;
|
||||||
|
|
||||||
//find the corresponding sslItem child item of the gpg item
|
//find the corresponding sslItem child item of the gpg item
|
||||||
bool newChild = true;
|
bool newChild = true;
|
||||||
@ -486,9 +490,6 @@ void PeersDialog::insertPeers()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newChild) {
|
|
||||||
sslItem = new QTreeWidgetItem(1); //set type to 1 for custom popup menu
|
|
||||||
}
|
|
||||||
|
|
||||||
RsPeerDetails sslDetail;
|
RsPeerDetails sslDetail;
|
||||||
if (!rsPeers->getPeerDetails(*sslIt, sslDetail) || !rsPeers->isFriend(*sslIt)) {
|
if (!rsPeers->getPeerDetails(*sslIt, sslDetail) || !rsPeers->isFriend(*sslIt)) {
|
||||||
@ -496,7 +497,13 @@ void PeersDialog::insertPeers()
|
|||||||
std::cerr << "Removing widget from the view : id : " << *sslIt << std::endl;
|
std::cerr << "Removing widget from the view : id : " << *sslIt << std::endl;
|
||||||
#endif
|
#endif
|
||||||
//child has disappeared, remove it from the gpg_item
|
//child has disappeared, remove it from the gpg_item
|
||||||
gpg_item->removeChild(sslItem);
|
if (sslItem) {
|
||||||
|
gpg_item->removeChild(sslItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newChild) {
|
||||||
|
sslItem = new QTreeWidgetItem(1); //set type to 1 for custom popup menu
|
||||||
}
|
}
|
||||||
|
|
||||||
/* not displayed, used to find back the item */
|
/* not displayed, used to find back the item */
|
||||||
@ -557,8 +564,8 @@ void PeersDialog::insertPeers()
|
|||||||
std::cerr << "PeersDialog::insertPeers() inserting sslItem." << std::endl;
|
std::cerr << "PeersDialog::insertPeers() inserting sslItem." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
/* add sl child to the list. If item is already in the list, it won't be duplicated thanks to Qt */
|
/* add sl child to the list. If item is already in the list, it won't be duplicated thanks to Qt */
|
||||||
gpg_item->addChild(sslItem);
|
|
||||||
if (newChild) {
|
if (newChild) {
|
||||||
|
gpg_item->addChild(sslItem);
|
||||||
gpg_item->setExpanded(true);
|
gpg_item->setExpanded(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1099,6 +1106,7 @@ void PeersDialog::sendMsg()
|
|||||||
|
|
||||||
void PeersDialog::insertSendList()
|
void PeersDialog::insertSendList()
|
||||||
{
|
{
|
||||||
|
#ifdef false
|
||||||
std::list<std::string> peers;
|
std::list<std::string> peers;
|
||||||
std::list<std::string>::iterator it;
|
std::list<std::string>::iterator it;
|
||||||
|
|
||||||
@ -1160,6 +1168,7 @@ void PeersDialog::insertSendList()
|
|||||||
//sendWidget->insertTopLevelItems(0, items);
|
//sendWidget->insertTopLevelItems(0, items);
|
||||||
|
|
||||||
//sendWidget->update(); /* update display */
|
//sendWidget->update(); /* update display */
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,6 +188,8 @@ int IntroPage::nextId() const
|
|||||||
if (textRadioButton->isChecked()) return ConnectFriendWizard::Page_Text;
|
if (textRadioButton->isChecked()) return ConnectFriendWizard::Page_Text;
|
||||||
if (certRadioButton->isChecked()) return ConnectFriendWizard::Page_Cert;
|
if (certRadioButton->isChecked()) return ConnectFriendWizard::Page_Cert;
|
||||||
if (foffRadioButton->isChecked()) return ConnectFriendWizard::Page_Foff;
|
if (foffRadioButton->isChecked()) return ConnectFriendWizard::Page_Foff;
|
||||||
|
|
||||||
|
return ConnectFriendWizard::Page_Foff;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
Loading…
Reference in New Issue
Block a user