summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/genericwrapper.cpp6
-rw-r--r--noncore/net/mail/imapwrapper.cpp12
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp6
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp12
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.cpp2
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.cpp12
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp29
-rw-r--r--noncore/net/mail/mailwrapper.cpp2
-rw-r--r--noncore/net/mail/mboxwrapper.cpp12
-rw-r--r--noncore/net/mail/smtpwrapper.cpp29
10 files changed, 80 insertions, 42 deletions
diff --git a/noncore/net/mail/genericwrapper.cpp b/noncore/net/mail/genericwrapper.cpp
index 447cad0..c1b6e48 100644
--- a/noncore/net/mail/genericwrapper.cpp
+++ b/noncore/net/mail/genericwrapper.cpp
@@ -191,9 +191,9 @@ RecMail *Genericwrapper::parseHeader( const char *header )
int err = MAILIMF_NO_ERROR;
size_t curTok = 0;
RecMail *mail = new RecMail();
- mailimf_fields *fields;
- mailimf_references * refs;
- mailimf_keywords*keys;
+ mailimf_fields *fields = 0;
+ mailimf_references * refs = 0;
+ mailimf_keywords*keys = 0;
QString status;
QString value;
QBitArray mFlags(7);
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index 853e4a2..0178e33 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -94,13 +94,13 @@ void IMAPwrapper::logout()
void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
{
- const char *mb;
+ const char *mb = 0;
int err = MAILIMAP_NO_ERROR;
- clist *result;
+ clist *result = 0;
clistcell *current;
// mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize;
- mailimap_fetch_type *fetchType;
- mailimap_set *set;
+ mailimap_fetch_type *fetchType = 0;
+ mailimap_set *set = 0;
mb = mailbox.latin1();
login();
@@ -121,7 +121,6 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
return;
}
- result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( 1, last );
fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
@@ -137,7 +136,6 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
QString date,subject,from;
if ( err == MAILIMAP_NO_ERROR ) {
-
mailimap_msg_att * msg_att;
int i = 0;
for (current = clist_begin(result); current != 0; current=clist_next(current)) {
@@ -154,7 +152,7 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
} else {
qDebug("Error fetching headers: %s",m_imap->imap_response);
}
- mailimap_fetch_list_free(result);
+ if (result) mailimap_fetch_list_free(result);
}
QList<Folder>* IMAPwrapper::listFolders()
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
index 447cad0..c1b6e48 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
@@ -191,9 +191,9 @@ RecMail *Genericwrapper::parseHeader( const char *header )
int err = MAILIMF_NO_ERROR;
size_t curTok = 0;
RecMail *mail = new RecMail();
- mailimf_fields *fields;
- mailimf_references * refs;
- mailimf_keywords*keys;
+ mailimf_fields *fields = 0;
+ mailimf_references * refs = 0;
+ mailimf_keywords*keys = 0;
QString status;
QString value;
QBitArray mFlags(7);
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 853e4a2..0178e33 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -94,13 +94,13 @@ void IMAPwrapper::logout()
void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
{
- const char *mb;
+ const char *mb = 0;
int err = MAILIMAP_NO_ERROR;
- clist *result;
+ clist *result = 0;
clistcell *current;
// mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize;
- mailimap_fetch_type *fetchType;
- mailimap_set *set;
+ mailimap_fetch_type *fetchType = 0;
+ mailimap_set *set = 0;
mb = mailbox.latin1();
login();
@@ -121,7 +121,6 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
return;
}
- result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( 1, last );
fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
@@ -137,7 +136,6 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
QString date,subject,from;
if ( err == MAILIMAP_NO_ERROR ) {
-
mailimap_msg_att * msg_att;
int i = 0;
for (current = clist_begin(result); current != 0; current=clist_next(current)) {
@@ -154,7 +152,7 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
} else {
qDebug("Error fetching headers: %s",m_imap->imap_response);
}
- mailimap_fetch_list_free(result);
+ if (result) mailimap_fetch_list_free(result);
}
QList<Folder>* IMAPwrapper::listFolders()
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
index f8efd09..6479783 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
@@ -55,7 +55,7 @@ QString IMAPFolder::decodeFolderName( const QString &name )
unsigned long ucs4, utf16, bitbuf;
unsigned char base64[256], utf8[6];
unsigned long srcPtr = 0;
- QCString dst;
+ QCString dst = "";
QCString src = name.ascii();
/* initialize modified base64 decoding table */
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
index 293ae1b..6d69263 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
@@ -4,6 +4,7 @@
#include <libetpan/libetpan.h>
#include <libetpan/mailstorage.h>
#include <qdir.h>
+#include <stdlib.h>
MBOXwrapper::MBOXwrapper(const QString & mbox_dir)
: Genericwrapper(),MBOXPath(mbox_dir)
@@ -23,15 +24,19 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
mailstorage*storage = mailstorage_new(NULL);
QString p = MBOXPath+"/";
p+=mailbox;
+ char*fname = 0;
- int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0);
+ fname = strdup(p.latin1());
+
+ int r = mbox_mailstorage_init(storage,fname,0,0,0);
mailfolder*folder;
- folder = mailfolder_new( storage,strdup(p.latin1()),NULL);
+ folder = mailfolder_new( storage,fname,NULL);
r = mailfolder_connect(folder);
if (r != MAIL_NO_ERROR) {
qDebug("Error initializing mbox");
mailfolder_free(folder);
mailstorage_free(storage);
+ free(fname);
return;
}
mailmessage_list * env_list = 0;
@@ -40,6 +45,7 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
qDebug("Error message list");
mailfolder_free(folder);
mailstorage_free(storage);
+ free(fname);
return;
}
r = mailsession_get_envelopes_list(folder->fld_session, env_list);
@@ -50,6 +56,7 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
}
mailfolder_free(folder);
mailstorage_free(storage);
+ free(fname);
return;
}
mailimf_references * refs;
@@ -103,6 +110,7 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
mailfolder_disconnect(folder);
mailfolder_free(folder);
mailstorage_free(storage);
+ free(fname);
}
QList<Folder>* MBOXwrapper::listFolders()
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
index a7e4837..21992b4 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
@@ -441,7 +441,9 @@ char *SMTPwrapper::getFrom( mailimf_field *ffrom)
char *SMTPwrapper::getFrom( mailmime *mail )
{
+ /* no need to delete - its just a pointer to structure content */
mailimf_field *ffrom = 0;
+ char*f = 0;
ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM );
return getFrom(ffrom);
}
@@ -563,6 +565,9 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
from = getFrom( mail );
rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
smtpSend(from,rcpts,data,size,smtp);
+ if (data) {free(data);}
+ if (from) {free(from);}
+ if (rcpts) smtp_address_list_free( rcpts );
}
int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp )
@@ -630,10 +635,7 @@ free_con_session:
free_mem_session:
mailsmtp_free( session );
free_mem:
- if (rcpts) smtp_address_list_free( rcpts );
- if (data) free( data );
if (server) free( server );
- if (from) free( from );
if ( smtp->getLogin() ) {
free( user );
free( pass );
@@ -652,7 +654,6 @@ void SMTPwrapper::sendMail(const Mail&mail,bool later )
qDebug( "sendMail: error creating mime mail" );
} else {
sendProgress = new progressMailSend();
-// sendProgress->showMaximized();
sendProgress->show();
sendProgress->setMaxMails(1);
smtpSend( mimeMail,later,smtp);
@@ -673,6 +674,7 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
mailimf_field*ffrom = 0;
clist *rcpts = 0;
char*from = 0;
+ int res = 0;
wrap->fetchRawBody(*which,&data,&length);
if (!data) return 0;
@@ -689,9 +691,22 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
qDebug("Size: %i vs. %i",length,strlen(data));
if (rcpts && from) {
- return smtpSend(from,rcpts,data,strlen(data),smtp );
+ res = smtpSend(from,rcpts,data,length,smtp );
}
- return 0;
+ if (fields) {
+ mailimf_fields_free(fields);
+ fields = 0;
+ }
+ if (data) {
+ free(data);
+ }
+ if (from) {
+ free(from);
+ }
+ if (rcpts) {
+ smtp_address_list_free( rcpts );
+ }
+ return res;
}
/* this is a special fun */
@@ -717,7 +732,6 @@ bool SMTPwrapper::flushOutbox(SMTPaccount*smtp)
}
mailsToSend.setAutoDelete(false);
sendProgress = new progressMailSend();
-// sendProgress->showMaximized();
sendProgress->show();
sendProgress->setMaxMails(mailsToSend.count());
@@ -740,5 +754,4 @@ bool SMTPwrapper::flushOutbox(SMTPaccount*smtp)
mailsToSend.setAutoDelete(true);
delete wrap;
return returnValue;
-
}
diff --git a/noncore/net/mail/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp
index f8efd09..6479783 100644
--- a/noncore/net/mail/mailwrapper.cpp
+++ b/noncore/net/mail/mailwrapper.cpp
@@ -55,7 +55,7 @@ QString IMAPFolder::decodeFolderName( const QString &name )
unsigned long ucs4, utf16, bitbuf;
unsigned char base64[256], utf8[6];
unsigned long srcPtr = 0;
- QCString dst;
+ QCString dst = "";
QCString src = name.ascii();
/* initialize modified base64 decoding table */
diff --git a/noncore/net/mail/mboxwrapper.cpp b/noncore/net/mail/mboxwrapper.cpp
index 293ae1b..6d69263 100644
--- a/noncore/net/mail/mboxwrapper.cpp
+++ b/noncore/net/mail/mboxwrapper.cpp
@@ -4,6 +4,7 @@
#include <libetpan/libetpan.h>
#include <libetpan/mailstorage.h>
#include <qdir.h>
+#include <stdlib.h>
MBOXwrapper::MBOXwrapper(const QString & mbox_dir)
: Genericwrapper(),MBOXPath(mbox_dir)
@@ -23,15 +24,19 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
mailstorage*storage = mailstorage_new(NULL);
QString p = MBOXPath+"/";
p+=mailbox;
+ char*fname = 0;
- int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0);
+ fname = strdup(p.latin1());
+
+ int r = mbox_mailstorage_init(storage,fname,0,0,0);
mailfolder*folder;
- folder = mailfolder_new( storage,strdup(p.latin1()),NULL);
+ folder = mailfolder_new( storage,fname,NULL);
r = mailfolder_connect(folder);
if (r != MAIL_NO_ERROR) {
qDebug("Error initializing mbox");
mailfolder_free(folder);
mailstorage_free(storage);
+ free(fname);
return;
}
mailmessage_list * env_list = 0;
@@ -40,6 +45,7 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
qDebug("Error message list");
mailfolder_free(folder);
mailstorage_free(storage);
+ free(fname);
return;
}
r = mailsession_get_envelopes_list(folder->fld_session, env_list);
@@ -50,6 +56,7 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
}
mailfolder_free(folder);
mailstorage_free(storage);
+ free(fname);
return;
}
mailimf_references * refs;
@@ -103,6 +110,7 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
mailfolder_disconnect(folder);
mailfolder_free(folder);
mailstorage_free(storage);
+ free(fname);
}
QList<Folder>* MBOXwrapper::listFolders()
diff --git a/noncore/net/mail/smtpwrapper.cpp b/noncore/net/mail/smtpwrapper.cpp
index a7e4837..21992b4 100644
--- a/noncore/net/mail/smtpwrapper.cpp
+++ b/noncore/net/mail/smtpwrapper.cpp
@@ -441,7 +441,9 @@ char *SMTPwrapper::getFrom( mailimf_field *ffrom)
char *SMTPwrapper::getFrom( mailmime *mail )
{
+ /* no need to delete - its just a pointer to structure content */
mailimf_field *ffrom = 0;
+ char*f = 0;
ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM );
return getFrom(ffrom);
}
@@ -563,6 +565,9 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
from = getFrom( mail );
rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
smtpSend(from,rcpts,data,size,smtp);
+ if (data) {free(data);}
+ if (from) {free(from);}
+ if (rcpts) smtp_address_list_free( rcpts );
}
int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp )
@@ -630,10 +635,7 @@ free_con_session:
free_mem_session:
mailsmtp_free( session );
free_mem:
- if (rcpts) smtp_address_list_free( rcpts );
- if (data) free( data );
if (server) free( server );
- if (from) free( from );
if ( smtp->getLogin() ) {
free( user );
free( pass );
@@ -652,7 +654,6 @@ void SMTPwrapper::sendMail(const Mail&mail,bool later )
qDebug( "sendMail: error creating mime mail" );
} else {
sendProgress = new progressMailSend();
-// sendProgress->showMaximized();
sendProgress->show();
sendProgress->setMaxMails(1);
smtpSend( mimeMail,later,smtp);
@@ -673,6 +674,7 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
mailimf_field*ffrom = 0;
clist *rcpts = 0;
char*from = 0;
+ int res = 0;
wrap->fetchRawBody(*which,&data,&length);
if (!data) return 0;
@@ -689,9 +691,22 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
qDebug("Size: %i vs. %i",length,strlen(data));
if (rcpts && from) {
- return smtpSend(from,rcpts,data,strlen(data),smtp );
+ res = smtpSend(from,rcpts,data,length,smtp );
}
- return 0;
+ if (fields) {
+ mailimf_fields_free(fields);
+ fields = 0;
+ }
+ if (data) {
+ free(data);
+ }
+ if (from) {
+ free(from);
+ }
+ if (rcpts) {
+ smtp_address_list_free( rcpts );
+ }
+ return res;
}
/* this is a special fun */
@@ -717,7 +732,6 @@ bool SMTPwrapper::flushOutbox(SMTPaccount*smtp)
}
mailsToSend.setAutoDelete(false);
sendProgress = new progressMailSend();
-// sendProgress->showMaximized();
sendProgress->show();
sendProgress->setMaxMails(mailsToSend.count());
@@ -740,5 +754,4 @@ bool SMTPwrapper::flushOutbox(SMTPaccount*smtp)
mailsToSend.setAutoDelete(true);
delete wrap;
return returnValue;
-
}