Archived Forum Post

Index of archived forum posts


C++ CkString copy constructor bug

Jul 20 '14 at 13:50

I'm not sure which version of the ChilKat libs we're using (where can I find this ?). It was downloaded more than a year ago.

We discovered a bug in our SMTP mail functionality which uses ChilKat mail.

When trying to send a mail with a file attachment this would sometimes silently fail to attach the file when the filename contained certain ansi characters (such as é)

The mail is sent out, but the attachment isn't present in the mail, and the CkEmail::AddFileAttachment() returns true.

We tracked this down to a bug in the CkString copy constructor.

Reproducible with this bit of code:

CkString strAnsi = "This is an ansi string containing é";
CkString strCopy (strAnsi);

strCopy is now flagged as a utf8 string (even though strAnsi is not), but the contents of the strCopy string is just a flat copy of the strAnsi contents. the ansi encoding isn't converted to utf8 encoding, so you end up with an invalidly encoded utf8 string. Apparently using this for CkEmail::AddFileAttachment() makes the function return true but doesn't attach the file.

It can be worked around by avoiding the copy constructor

CkString strCopy;
strCopy = strAnsi;

gives the desired result.


This problem has been fixed and will be included in the next release after v9.5.0.41.