Skip to content

Commit 38abd54

Browse files
author
Ata Kuyumcu
authored
Merge pull request #13 from liangwu/patch-1
fixed a bug on windows
2 parents 53b37f8 + b519f28 commit 38abd54

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/countly.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ using json = nlohmann::json;
1717
#ifdef _WIN32
1818
#include "Windows.h"
1919
#include "WinHTTP.h"
20+
#pragma comment(lib, "winhttp.lib")
2021
#else
2122
#include "curl/curl.h"
2223
#endif
@@ -695,7 +696,7 @@ Countly::HTTPResponse Countly::sendHTTP(std::string path, std::string data) {
695696
if (hRequest) {
696697
bool ok = WinHttpSendRequest(hRequest, WINHTTP_NO_ADDITIONAL_HEADERS, 0, use_post ? data.c_str() : WINHTTP_NO_REQUEST_DATA, use_post ? data.size() : 0, 0, nullptr) != 0;
697698
if (ok) {
698-
ok = !WinHttpReceiveResponse(hRequest, NULL);
699+
ok = WinHttpReceiveResponse(hRequest, NULL);
699700
if (ok) {
700701
DWORD dwStatusCode = 0;
701702
DWORD dwSize = sizeof(dwStatusCode);
@@ -716,7 +717,8 @@ Countly::HTTPResponse Countly::sendHTTP(std::string path, std::string data) {
716717
break;
717718
}
718719

719-
char *body_part = new char[n_bytes_available];
720+
char *body_part = new char[n_bytes_available+1];
721+
memset(body_part, 0, n_bytes_available+1);
720722
DWORD n_bytes_read = 0;
721723

722724
if (!WinHttpReadData(hRequest, body_part, n_bytes_available, &n_bytes_read)) {

0 commit comments

Comments
 (0)