From 8f4b6869f178c12a43d7d37336f32f8ecf7b1427 Mon Sep 17 00:00:00 2001 From: Diadlo Date: Fri, 8 Apr 2016 02:06:03 +0300 Subject: [PATCH] fix(toxme): Fixed potential memory leaks --- src/net/toxme.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/net/toxme.cpp b/src/net/toxme.cpp index d24321cc6..1d0b0ff95 100644 --- a/src/net/toxme.cpp +++ b/src/net/toxme.cpp @@ -54,7 +54,9 @@ QByteArray Toxme::makeJsonRequest(QString url, QString json, QNetworkReply::Netw return QByteArray(); } - return reply->readAll(); + QByteArray result = reply->readAll(); + delete reply; + return result; } QByteArray Toxme::getServerPubkey(QString url, QNetworkReply::NetworkError &error) @@ -236,7 +238,8 @@ QString Toxme::createAddress(ExecCode &code, QString server, ToxId id, QString a QString pubkeyUrl = server + "/pk"; QString apiUrl = server + "/api"; QNetworkReply::NetworkError error = QNetworkReply::NoError; - QByteArray response = makeJsonRequest(apiUrl, prepareEncryptedJson(pubkeyUrl, 1, payload), error); + QByteArray encrypted = prepareEncryptedJson(pubkeyUrl, 1, payload); + QByteArray response = makeJsonRequest(apiUrl, encrypted, error); qDebug() << response; code = extractError(response);