mirror of
https://github.com/SChernykh/p2pool.git
synced 2025-01-03 17:29:24 +00:00
Fixed unaligned read
This commit is contained in:
parent
b25e5449c8
commit
a281db1cbb
2 changed files with 2 additions and 2 deletions
|
@ -132,7 +132,7 @@ void StratumServer::on_block(const BlockTemplate& block)
|
||||||
|
|
||||||
// Get first 8 bytes of the Merkle root hash from each blob
|
// Get first 8 bytes of the Merkle root hash from each blob
|
||||||
for (size_t i = 0; i < num_connections; ++i) {
|
for (size_t i = 0; i < num_connections; ++i) {
|
||||||
blob_hashes.emplace_back(*reinterpret_cast<const uint64_t*>(data + i * size + 43));
|
blob_hashes.emplace_back(read_unaligned(reinterpret_cast<const uint64_t*>(data + i * size + 43)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find duplicates
|
// Find duplicates
|
||||||
|
|
|
@ -136,7 +136,7 @@ const uint8_t* readVarint(const uint8_t* data, const uint8_t* data_end, T& b)
|
||||||
template<typename T>
|
template<typename T>
|
||||||
FORCEINLINE T read_unaligned(const T* p)
|
FORCEINLINE T read_unaligned(const T* p)
|
||||||
{
|
{
|
||||||
static_assert(std::is_integral<T>::value, "T must be an integer type");
|
static_assert(std::is_trivially_copyable<T>::value, "T must be a trivially copyable type");
|
||||||
|
|
||||||
T result;
|
T result;
|
||||||
memcpy(&result, p, sizeof(T));
|
memcpy(&result, p, sizeof(T));
|
||||||
|
|
Loading…
Reference in a new issue