Skip to content

Commit

Permalink
Merge pull request #89 from wiktordrewniak/cpp11-fix-unaligned-access
Browse files Browse the repository at this point in the history
Fix address sanitizer alignment error
  • Loading branch information
dascandy authored Nov 26, 2018
2 parents 8f05dd6 + b4fc1e9 commit 1e91c50
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion HippoMocks/detail/replace.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ class Replace
if (llabs((long long)origFunc - (long long)replacement) < 0x80000000LL) {
# endif
*(unsigned char *)origFunc = 0xE9;
*(e9ptrsize_t*)(horrible_cast<intptr_t>(origFunc) + 1) = (e9ptrsize_t)(horrible_cast<intptr_t>(replacement) - horrible_cast<intptr_t>(origFunc) - sizeof(e9ptrsize_t) - 1);
e9ptrsize_t temp_address = (e9ptrsize_t)(horrible_cast<intptr_t>(replacement) - horrible_cast<intptr_t>(origFunc) - sizeof(e9ptrsize_t) - 1);
memcpy((e9ptrsize_t*)(horrible_cast<intptr_t>(origFunc) + 1), &temp_address, sizeof(e9ptrsize_t));
# ifdef CMOCK_FUNC_PLATFORMIS64BIT
} else {
unsigned char *func = (unsigned char *)origFunc;
Expand Down

0 comments on commit 1e91c50

Please sign in to comment.