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:
parent
aa20df7144
commit
cbade4bae6
|
@ -129,6 +129,9 @@ void Core::makeTox(QByteArray savedata)
|
||||||
bool enableIPv6 = Settings::getInstance().getEnableIPv6();
|
bool enableIPv6 = Settings::getInstance().getEnableIPv6();
|
||||||
bool forceTCP = Settings::getInstance().getForceTCP();
|
bool forceTCP = Settings::getInstance().getForceTCP();
|
||||||
ProxyType proxyType = Settings::getInstance().getProxyType();
|
ProxyType proxyType = Settings::getInstance().getProxyType();
|
||||||
|
int proxyPort = Settings::getInstance().getProxyPort();
|
||||||
|
QString proxyAddr = Settings::getInstance().getProxyAddr();
|
||||||
|
QByteArray proxyAddrData = proxyAddr.toUtf8();
|
||||||
|
|
||||||
if (enableIPv6)
|
if (enableIPv6)
|
||||||
qDebug() << "Core starting with IPv6 enabled";
|
qDebug() << "Core starting with IPv6 enabled";
|
||||||
|
@ -152,9 +155,6 @@ void Core::makeTox(QByteArray savedata)
|
||||||
|
|
||||||
if (proxyType != ProxyType::ptNone)
|
if (proxyType != ProxyType::ptNone)
|
||||||
{
|
{
|
||||||
QString proxyAddr = Settings::getInstance().getProxyAddr();
|
|
||||||
int proxyPort = Settings::getInstance().getProxyPort();
|
|
||||||
|
|
||||||
if (proxyAddr.length() > 255)
|
if (proxyAddr.length() > 255)
|
||||||
{
|
{
|
||||||
qWarning() << "proxy address" << proxyAddr << "is too long";
|
qWarning() << "proxy address" << proxyAddr << "is too long";
|
||||||
|
@ -168,11 +168,7 @@ void Core::makeTox(QByteArray savedata)
|
||||||
else if (proxyType == ProxyType::ptHTTP)
|
else if (proxyType == ProxyType::ptHTTP)
|
||||||
toxOptions.proxy_type = TOX_PROXY_TYPE_HTTP;
|
toxOptions.proxy_type = TOX_PROXY_TYPE_HTTP;
|
||||||
|
|
||||||
QByteArray proxyAddrData = proxyAddr.toUtf8();
|
toxOptions.proxy_host = proxyAddrData.data();
|
||||||
/// 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_port = proxyPort;
|
toxOptions.proxy_port = proxyPort;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user