Architecture ARM9. Programming Language C.
We have a third-party stack and one of the calls takes a pointer(pBuffer
) to a memory location. Within the stack, they are free to move around the pointer passed and access it as they wish. Unfortunately, they offset the passed in pointer and passed it into a another function that tried to do this from an odd/unalighed memory location
((uint16 *)pBuffer)[index] = value;
where value
is of type uint16
and index
is bounds checked and indexes pBuffer
. This causes a unaligned memory access exception. pBuffer
points to char *
on the heap.
As mentioned, even though we can peek into the third-party stack, we can not update the code officially. So we notify the provider and they provide the update in the next release.
I want to understand if there is a work around for this. How do I perform the above assignment without violating the unaligned access? What is the best approach to resolving such problems.