diff --git a/src/base/io/log/backends/FileLog.cpp b/src/base/io/log/backends/FileLog.cpp index 1ff016371..c581b880d 100644 --- a/src/base/io/log/backends/FileLog.cpp +++ b/src/base/io/log/backends/FileLog.cpp @@ -24,13 +24,14 @@ */ -#include -#include - - #include "base/io/log/backends/FileLog.h" +#include +#include +#include + + xmrig::FileLog::FileLog(const char *fileName) { uv_fs_t req; @@ -45,13 +46,12 @@ void xmrig::FileLog::print(int, const char *line, size_t, size_t size, bool colo return; } -# ifdef _WIN32 - uv_buf_t buf = uv_buf_init(strdup(line), static_cast(size)); -# else - uv_buf_t buf = uv_buf_init(strdup(line), size); -# endif + assert(strlen(line) == size); - uv_fs_t *req = new uv_fs_t; + uv_buf_t buf = uv_buf_init(new char[size], size); + memcpy(buf.base, line, size); + + auto req = new uv_fs_t; req->data = buf.base; uv_fs_write(uv_default_loop(), req, m_file, &buf, 1, -1, FileLog::onWrite);