szaszm commented on a change in pull request #928: URL: https://github.com/apache/nifi-minifi-cpp/pull/928#discussion_r508369819
########## File path: extensions/windows-event-log/wel/WindowsEventLog.cpp ########## @@ -129,34 +133,30 @@ std::string WindowsEventLogMetadataImpl::getEventData(EVT_FORMAT_MESSAGE_FLAGS f return event_data; } - if (!EvtFormatMessage(metadata_ptr_, event_ptr_, 0, 0, NULL, flags, string_buffer_size, string_buffer, &string_buffer_used)) { + + if (!EvtFormatMessage(metadata_ptr_, event_ptr_, 0, 0, NULL, flags, string_buffer_size, string_buffer.get(), &string_buffer_used)) { result = GetLastError(); if (ERROR_INSUFFICIENT_BUFFER == result) { string_buffer_size = string_buffer_used; - string_buffer = (LPWSTR) malloc(string_buffer_size * sizeof(WCHAR)); - - if (string_buffer) { + string_buffer.reset((LPWSTR) malloc(string_buffer_size * sizeof(WCHAR))); Review comment: Again, this should allocate `string_buffer_used`. No multiplication with `sizeof(WCHAR)` needed, because the size is already in bytes. ########## File path: extensions/windows-event-log/wel/WindowsEventLog.cpp ########## @@ -43,10 +45,10 @@ void WindowsEventLogMetadataImpl::renderMetadata() { const auto contextGuard = gsl::finally([&context](){ EvtClose(context); }); - if (!EvtRender(context, event_ptr_, EvtRenderEventValues, dwBufferSize, nullptr, &dwBufferUsed, &dwPropertyCount)) { + if (!EvtRender(context, event_ptr_, EvtRenderEventValues, dwBufferSize, rendered_values.get(), &dwBufferUsed, &dwPropertyCount)) { if (ERROR_INSUFFICIENT_BUFFER == (status = GetLastError())) { dwBufferSize = dwBufferUsed; - rendered_values = std::unique_ptr<EVT_VARIANT, utils::FreeDeleter>((PEVT_VARIANT)(malloc(dwBufferSize))); + rendered_values.reset((PEVT_VARIANT)(malloc(dwBufferSize))); Review comment: This should allocate `dwBufferUsed` bytes as that's the out param of `EvtRender`. I assume this is a typo, because it's used correctly elsewhere. ```suggestion rendered_values.reset((PEVT_VARIANT)(malloc(dwBufferUsed))); ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org