[PATCH 3/9] qi-fix-malloc-alignment.patch

Andy Green andy at openmoko.com
Fri Sep 26 14:55:27 CEST 2008


Noticed malloc() could become unaligned

Signed-off-by: Andy Green <andy at openmoko.com>
---

 src/utils.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/utils.c b/src/utils.c
index 3d72ec2..7e92288 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -271,7 +271,7 @@ void *malloc(size_t size)
 {
 	void *p = malloc_pointer;
 
-	malloc_pointer += size;
+	malloc_pointer += (size & ~3) + 4;
 
 	if (((u8 *)malloc_pointer - &malloc_pool[0]) > sizeof(malloc_pool)) {
 		puts("Ran out of malloc pool\n");




More information about the openmoko-kernel mailing list