diff options
author | grehan <grehan@FreeBSD.org> | 2004-02-25 00:52:14 +0000 |
---|---|---|
committer | grehan <grehan@FreeBSD.org> | 2004-02-25 00:52:14 +0000 |
commit | a8135829fff2b8ce3ed90e60401a09a6f3483621 (patch) | |
tree | 5127940f781b156275945e15f7db6d4d66dffa8e /lib | |
parent | d5e84fec77a62eee3015afabb91bc13ab6e758f3 (diff) | |
download | FreeBSD-src-a8135829fff2b8ce3ed90e60401a09a6f3483621.zip FreeBSD-src-a8135829fff2b8ce3ed90e60401a09a6f3483621.tar.gz |
Use signed char cast to avoid out-of-range error on PowerPC (which has
unsigned char by default). This is a no-op on all other current arches.
Tested by: md5 sum before/after same on i386
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libstand/zalloc_malloc.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libstand/zalloc_malloc.c b/lib/libstand/zalloc_malloc.c index fcc54dc..3161fc3 100644 --- a/lib/libstand/zalloc_malloc.c +++ b/lib/libstand/zalloc_malloc.c @@ -88,8 +88,9 @@ Malloc(size_t bytes, const char *file, int line) #endif res->ga_Bytes = bytes; #ifdef USEENDGUARD - *((char *)res + bytes - 1) = -2; + *((signed char *)res + bytes - 1) = -2; #endif + return((char *)res + MALLOCALIGN); } @@ -113,13 +114,13 @@ Free(void *ptr, const char *file, int line) res->ga_Magic = GAFREE; #endif #ifdef USEENDGUARD - if (*((char *)res + res->ga_Bytes - 1) == -1) { + if (*((signed char *)res + res->ga_Bytes - 1) == -1) { printf("free: duplicate2 free @ %p from %s:%d\n", ptr, file, line); return; } - if (*((char *)res + res->ga_Bytes - 1) != -2) + if (*((signed char *)res + res->ga_Bytes - 1) != -2) panic("free: guard2 fail @ %p + %d from %s:%d", ptr, res->ga_Bytes - MALLOCALIGN, file, line); - *((char *)res + res->ga_Bytes - 1) = -1; + *((signed char *)res + res->ga_Bytes - 1) = -1; #endif bytes = res->ga_Bytes; |