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:
thunder2 2010-05-12 20:10:22 +00:00
parent faace1f322
commit b242b73f31
4 changed files with 32 additions and 15 deletions

View File

@ -629,8 +629,6 @@ bool ftController::copyFile(const std::string& source,const std::string& dest)
{
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") ;
if(in == NULL)
@ -644,12 +642,18 @@ bool ftController::copyFile(const std::string& source,const std::string& dest)
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);
fclose (in);
return false ;
}
size_t s=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)
{
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)
{
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;
}
}

View File

@ -224,6 +224,7 @@ int pqissl::reset()
active = false;
sockfd = -1;
waiting = WAITING_NOT;
SSL_free (ssl_connection);
ssl_connection = NULL;
sameLAN = false;
n_read_zero = 0;

View File

@ -430,23 +430,27 @@ void PeersDialog::insertPeers()
#endif
/* make a widget per friend */
QTreeWidgetItem *gpg_item;
QTreeWidgetItem *gpg_item = NULL;
QList<QTreeWidgetItem *> list = peertreeWidget->findItems(QString::fromStdString(*it), Qt::MatchExactly, 3);
if (list.size() == 1) {
if (list.size() > 0) {
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;
if ((!rsPeers->getPeerDetails(*it, detail) || !detail.accept_connection)
&& detail.gpg_id != rsPeers->getGPGOwnId()) {
//don't accept anymore connection, remove from the view
if (gpg_item) {
delete (peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(gpg_item)));
}
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
gpg_item->setData(0, Qt::UserRole, true);
gpg_item -> setText(0, QString::fromStdString(detail.name));
@ -475,7 +479,7 @@ void PeersDialog::insertPeers()
std::list<std::string> sslContacts;
rsPeers->getSSLChildListOfGPGId(detail.gpg_id, sslContacts);
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
bool newChild = true;
@ -486,9 +490,6 @@ void PeersDialog::insertPeers()
break;
}
}
if (newChild) {
sslItem = new QTreeWidgetItem(1); //set type to 1 for custom popup menu
}
RsPeerDetails sslDetail;
if (!rsPeers->getPeerDetails(*sslIt, sslDetail) || !rsPeers->isFriend(*sslIt)) {
@ -496,8 +497,14 @@ void PeersDialog::insertPeers()
std::cerr << "Removing widget from the view : id : " << *sslIt << std::endl;
#endif
//child has disappeared, remove it from the gpg_item
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 */
sslItem -> setText(3, QString::fromStdString(sslDetail.id));
@ -557,8 +564,8 @@ void PeersDialog::insertPeers()
std::cerr << "PeersDialog::insertPeers() inserting sslItem." << std::endl;
#endif
/* 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) {
gpg_item->addChild(sslItem);
gpg_item->setExpanded(true);
}
}
@ -1099,6 +1106,7 @@ void PeersDialog::sendMsg()
void PeersDialog::insertSendList()
{
#ifdef false
std::list<std::string> peers;
std::list<std::string>::iterator it;
@ -1160,6 +1168,7 @@ void PeersDialog::insertSendList()
//sendWidget->insertTopLevelItems(0, items);
//sendWidget->update(); /* update display */
#endif
}

View File

@ -188,6 +188,8 @@ int IntroPage::nextId() const
if (textRadioButton->isChecked()) return ConnectFriendWizard::Page_Text;
if (certRadioButton->isChecked()) return ConnectFriendWizard::Page_Cert;
if (foffRadioButton->isChecked()) return ConnectFriendWizard::Page_Foff;
return ConnectFriendWizard::Page_Foff;
}
//
//============================================================================