Skip to content

Commit

Permalink
NITWORK: Fix crash on some systems
Browse files Browse the repository at this point in the history
  • Loading branch information
Saverio976 committed Oct 21, 2023
1 parent fc3ce4e commit ab22723
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Nitwork/ANitwork.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <condition_variable>
#include <iostream>
#include <list>
#include <memory>
#include <mutex>
#include <unordered_map>
#include "INitwork.hpp"
Expand Down Expand Up @@ -62,18 +63,18 @@ namespace Nitwork {
HEADER_CODE2};
data.header = newHeader;
}
std::vector<char> compressedPacket = Zstd::compress(data);
std::shared_ptr<std::vector<char>> compressedPacket = std::make_shared<std::vector<char>>(Zstd::compress(data));

_socket.async_send_to(
boost::asio::buffer(compressedPacket),
boost::asio::buffer(*compressedPacket),
packet.endpoint,
[compressedPacket](const boost::system::error_code &error, std::size_t bytes_sent) {
Logger::debug("NITWORK: Package sent");
if (error) {
Logger::error("NITWORK: " + std::string(error.message()));
return;
}
if (bytes_sent != compressedPacket.size()) {
if (bytes_sent != compressedPacket->size()) {
Logger::error("NITWORK: Package not sent");
return;
}
Expand Down

0 comments on commit ab22723

Please sign in to comment.