Fix aligned memory read of unanligend memory
This commit is contained in:
parent
6dc4d620ee
commit
8df55d1594
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef __JABYENGINE_UNALIGNED_READ_HPP__
|
||||||
|
#define __JABYENGINE_UNALIGNED_READ_HPP__
|
||||||
|
#include "../../stdint.h"
|
||||||
|
|
||||||
|
namespace JabyEngine {
|
||||||
|
uint16_t unaligned_lhu(const uint8_t* adr) {
|
||||||
|
return (static_cast<uint16_t>(adr[0]) | static_cast<uint16_t>(adr[1]) << 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //!__JABYENGINE_UNALIGNED_READ_HPP__
|
|
@ -1,4 +1,5 @@
|
||||||
#include <PSX/Auxiliary/lz4_decompressor.hpp>
|
#include <PSX/Auxiliary/lz4_decompressor.hpp>
|
||||||
|
#include <PSX/Auxiliary/unaligned_read.hpp>
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
static void memcpy(uint8_t* &dst, ArrayRange<const uint8_t> &src, size_t size) {
|
static void memcpy(uint8_t* &dst, ArrayRange<const uint8_t> &src, size_t size) {
|
||||||
|
@ -94,7 +95,7 @@ namespace JabyEngine {
|
||||||
// We are unused and invalid
|
// We are unused and invalid
|
||||||
if(data.size >= sizeof(uint16_t)) {
|
if(data.size >= sizeof(uint16_t)) {
|
||||||
// We can read all
|
// We can read all
|
||||||
this->state.match_offset = *reinterpret_cast<const uint16_t*>(data.start);
|
this->state.match_offset = unaligned_lhu(data.start);
|
||||||
data.skip(sizeof(uint16_t));
|
data.skip(sizeof(uint16_t));
|
||||||
|
|
||||||
if(!state_complete(this->state)) {
|
if(!state_complete(this->state)) {
|
||||||
|
|
Loading…
Reference in New Issue