1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Fix tiny memory leak on startup

This commit is contained in:
tux3 2015-12-15 19:08:59 +01:00
parent aa20df7144
commit cbade4bae6
No known key found for this signature in database
GPG Key ID: 7E086DD661263264

View File

@ -129,6 +129,9 @@ void Core::makeTox(QByteArray savedata)
bool enableIPv6 = Settings::getInstance().getEnableIPv6();
bool forceTCP = Settings::getInstance().getForceTCP();
ProxyType proxyType = Settings::getInstance().getProxyType();
int proxyPort = Settings::getInstance().getProxyPort();
QString proxyAddr = Settings::getInstance().getProxyAddr();
QByteArray proxyAddrData = proxyAddr.toUtf8();
if (enableIPv6)
qDebug() << "Core starting with IPv6 enabled";
@ -152,9 +155,6 @@ void Core::makeTox(QByteArray savedata)
if (proxyType != ProxyType::ptNone)
{
QString proxyAddr = Settings::getInstance().getProxyAddr();
int proxyPort = Settings::getInstance().getProxyPort();
if (proxyAddr.length() > 255)
{
qWarning() << "proxy address" << proxyAddr << "is too long";
@ -168,11 +168,7 @@ void Core::makeTox(QByteArray savedata)
else if (proxyType == ProxyType::ptHTTP)
toxOptions.proxy_type = TOX_PROXY_TYPE_HTTP;
QByteArray proxyAddrData = proxyAddr.toUtf8();
/// TODO: We're leaking a tiny amount of memory there, go fix that later
char* proxyAddrCopy = new char[proxyAddrData.size()+1];
memcpy(proxyAddrCopy, proxyAddrData.data(), proxyAddrData.size()+1);
toxOptions.proxy_host = proxyAddrCopy;
toxOptions.proxy_host = proxyAddrData.data();
toxOptions.proxy_port = proxyPort;
}
}