Skip to content

Commit 5253824

Browse files
authored
[SDK 888] Memory leakage fixed (#69)
* memory leakage fixed init with nullptr fixed * memory leakage fixed
1 parent fd0f73d commit 5253824

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/countly.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -868,9 +868,9 @@ Countly::HTTPResponse Countly::sendHTTP(std::string path, std::string data) {
868868
return http_client_function(use_post, path, data);
869869
}
870870
#ifdef _WIN32
871-
HINTERNET hSession;
872-
HINTERNET hConnect;
873-
HINTERNET hRequest;
871+
HINTERNET hSession = nullptr;
872+
HINTERNET hConnect = nullptr;
873+
HINTERNET hRequest = nullptr;
874874

875875
hSession = WinHttpOpen(NULL, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
876876
if (hSession) {
@@ -895,7 +895,7 @@ Countly::HTTPResponse Countly::sendHTTP(std::string path, std::string data) {
895895
MultiByteToWideChar(CP_ACP, 0, path.c_str(), -1, wide_path, buffer_size);
896896

897897
hRequest = WinHttpOpenRequest(hConnect, use_post ? L"POST" : L"GET", wide_path, NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, use_https ? WINHTTP_FLAG_SECURE : 0);
898-
delete wide_path;
898+
delete[] wide_path;
899899
}
900900

901901
if (hRequest) {
@@ -929,12 +929,12 @@ Countly::HTTPResponse Countly::sendHTTP(std::string path, std::string data) {
929929

930930
if (!WinHttpReadData(hRequest, body_part, n_bytes_available, &n_bytes_read)) {
931931
error_reading_body = true;
932-
delete body_part;
932+
delete[] body_part;
933933
break;
934934
}
935935

936936
body += body_part;
937-
delete body_part;
937+
delete[] body_part;
938938
} while (n_bytes_available > 0);
939939

940940
if (!body.empty()) {

0 commit comments

Comments
 (0)