bluetiger9 / SmtpClient-for-Qt

An SMTP Client writen in C++ for Qt. Allows applications to send emails (MIME with text, html, attachments, inline files, etc.) via SMTP. Supports SSL and SMTP authentication.
https://github.com/bluetiger9/SmtpClient-for-Qt/wiki
GNU Lesser General Public License v2.1
449 stars 226 forks source link

Failed to connect, causes program to crash (actually attachments cause the problem) #113

Closed TheCentroid closed 2 years ago

TheCentroid commented 2 years ago

I have been trying to use your library in a project that I have been developing. I was basing my code on your Demo3 program. I accidently connected to the wrong port of the mail server and after a few minutes when the connection timed out, it correctly went to the "Failed to connect" step but also produced a 'pure virtual method called' exception. This crashed my program.

Altering Demo3 to have the same error in the port number produced a similar result but also additionally reported a 'terminate called without an active exception' error.

As our customers will need to set up the connection parameters themselves, we will need to be able to prevent the program from crashing if they get the details wrong, as I did.

Thank you for developing this library which, this issue aside, has proven to be very useful

TheCentroid commented 2 years ago

Hi. A but more testing has shown that this is not actually an issue when the system fails to connect but occurs when their is an attachment. The email actually gets sent properly but the program will exit afterwards regardless.

TheCentroid commented 2 years ago

The problem seems to be that in the module MimeFile , in its destructor you delete the variable file. This however is a pointer and hence does not need to be deleted and causes the issues I have raised.

bluetiger9 commented 2 years ago

Fixed this on the dev branch.