mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-24 22:30:42 -04:00
Memory leak fix
Removes unnecessary conversion code as well as a malloc that was never freed git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3080 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
21efccfdd6
commit
2af2b056f4
1 changed files with 3 additions and 22 deletions
|
@ -340,9 +340,6 @@ void PopupChatDialog::sendChat()
|
||||||
|
|
||||||
ChatInfo ci;
|
ChatInfo ci;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
rsiface->lockData(); /* Lock Interface */
|
rsiface->lockData(); /* Lock Interface */
|
||||||
const RsConfig &conf = rsiface->getConfig();
|
const RsConfig &conf = rsiface->getConfig();
|
||||||
|
@ -784,7 +781,6 @@ void PopupChatDialog::fileHashingFinished(AttachFileItem* file)
|
||||||
|
|
||||||
ChatInfo ci;
|
ChatInfo ci;
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
rsiface->lockData(); /* Lock Interface */
|
rsiface->lockData(); /* Lock Interface */
|
||||||
const RsConfig &conf = rsiface->getConfig();
|
const RsConfig &conf = rsiface->getConfig();
|
||||||
|
@ -795,28 +791,13 @@ void PopupChatDialog::fileHashingFinished(AttachFileItem* file)
|
||||||
rsiface->unlockData(); /* Unlock Interface */
|
rsiface->unlockData(); /* Unlock Interface */
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string mesgString = RetroShareLink(QString::fromStdString(file->FileName()),file->FileSize(),QString::fromStdString(file->FileHash())).toHtml().toStdString() ;
|
QString message = RetroShareLink(QString::fromStdString(file->FileName()),file->FileSize(),QString::fromStdString(file->FileHash())).toHtml();
|
||||||
|
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "PopupChatDialog::anchorClicked mesgString : " << mesgString << std::endl;
|
std::cerr << "PopupChatDialog::anchorClicked message : " << message.toStdString() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char * messageString = mesgString.c_str ();
|
ci.msg = message.toStdWString();
|
||||||
|
|
||||||
//convert char massageString to w_char
|
|
||||||
wchar_t* message;
|
|
||||||
int requiredSize = mbstowcs(NULL, messageString, 0); // C4996
|
|
||||||
/* Add one to leave room for the NULL terminator */
|
|
||||||
message = (wchar_t *)malloc( (requiredSize + 1) * sizeof( wchar_t ));
|
|
||||||
if (! message) {
|
|
||||||
std::cerr << ("Memory allocation failure.\n");
|
|
||||||
}
|
|
||||||
int size = mbstowcs( message, messageString, requiredSize + 1); // C4996
|
|
||||||
if (size == (size_t) (-1)) {
|
|
||||||
printf("Couldn't convert string--invalid multibyte character.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
ci.msg = message;
|
|
||||||
ci.chatflags = RS_CHAT_PRIVATE;
|
ci.chatflags = RS_CHAT_PRIVATE;
|
||||||
|
|
||||||
addChatMsg(&ci);
|
addChatMsg(&ci);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue