Added check whether unaligned memory access is allowed.
Added macros to access unaligned WORDs / DWORDs.
diff --git a/memory/environ.c b/memory/environ.c
index 6630137..e7bf71c 100644
--- a/memory/environ.c
+++ b/memory/environ.c
@@ -6,6 +6,7 @@
#include <stdlib.h>
#include <string.h>
+#include "wine/port.h"
#include "windef.h"
#include "winnls.h"
#include "winerror.h"
@@ -59,7 +60,7 @@
/* Fill the extra bytes with the program name and stuff */
#define FILL_EXTRA_ENV(p) \
*(p) = '\0'; \
- PUT_WORD( (p) + 1, 1 ); \
+ PUT_UA_WORD( (p) + 1, 1 ); \
strcpy( (p) + 3, ENV_program_name );
STARTUPINFOA current_startupinfo =
diff --git a/memory/heap.c b/memory/heap.c
index 0437a0c..c73d52a 100644
--- a/memory/heap.c
+++ b/memory/heap.c
@@ -9,6 +9,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include "config.h"
#include "wine/winbase16.h"
#include "wine/unicode.h"
#include "selectors.h"
@@ -682,6 +683,16 @@
{
char *heapEnd = (char *)subheap + subheap->size;
+#if !defined(ALLOW_UNALIGNED_ACCESS)
+ /* Check for unaligned pointers */
+ if ( (long)pArena % sizeof(void *) != 0 )
+ {
+ ERR( "Heap %08lx: unaligned arena pointer %08lx\n",
+ (DWORD)subheap->heap, (DWORD)pArena );
+ return FALSE;
+ }
+#endif
+
/* Check magic number */
if (pArena->magic != ARENA_FREE_MAGIC)
{
@@ -766,6 +777,28 @@
{
char *heapEnd = (char *)subheap + subheap->size;
+#if !defined(ALLOW_UNALIGNED_ACCESS)
+ /* Check for unaligned pointers */
+ if ( (long)pArena % sizeof(void *) != 0 )
+ {
+ if ( quiet == NOISY )
+ {
+ ERR( "Heap %08lx: unaligned arena pointer %08lx\n",
+ (DWORD)subheap->heap, (DWORD)pArena );
+ if ( TRACE_ON(heap) )
+ HEAP_Dump( subheap->heap );
+ }
+ else if ( WARN_ON(heap) )
+ {
+ WARN( "Heap %08lx: unaligned arena pointer %08lx\n",
+ (DWORD)subheap->heap, (DWORD)pArena );
+ if ( TRACE_ON(heap) )
+ HEAP_Dump( subheap->heap );
+ }
+ return FALSE;
+ }
+#endif
+
/* Check magic number */
if (pArena->magic != ARENA_INUSE_MAGIC)
{