Skip to content

Commit

Permalink
Update LogCurl.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
SmileYzn authored Sep 18, 2024
1 parent d5f8b39 commit b9044ed
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions LogApi/LogCurl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,32 @@ void CLogCurl::PostJSON(const char* url, long Timeout, std::string BearerToken,

size_t CLogCurl::WriteMemoryCallback(void* contents, size_t size, size_t nmemb, void* userp)
{
size_t realsize = size * nmemb;

P_CURL_MOD_MEMORY* mem = (P_CURL_MOD_MEMORY*)userp;

char* ptr = (char*)realloc(mem->Memory, mem->Size + realsize + 1);

if (ptr)
if (contents)
{
mem->Memory = ptr;

memcpy(&(mem->Memory[mem->Size]), contents, realsize);

mem->Size += realsize;

mem->Memory[mem->Size] = 0;
if (userp)
{
size_t realsize = size * nmemb;

return realsize;
if (realsize > 0)
{
P_CURL_MOD_MEMORY* mem = (P_CURL_MOD_MEMORY*)userp;

char* ptr = (char*)realloc(mem->Memory, mem->Size + realsize + 1);

if (ptr)
{
mem->Memory = ptr;

memcpy(&(mem->Memory[mem->Size]), contents, realsize);

mem->Size += realsize;

mem->Memory[mem->Size] = 0;

return realsize;
}
}
}
}

return 0;
Expand Down

0 comments on commit b9044ed

Please sign in to comment.