diff options
author | Peter Grehan <grehan@FreeBSD.org> | 2004-02-25 00:52:14 +0000 |
---|---|---|
committer | Peter Grehan <grehan@FreeBSD.org> | 2004-02-25 00:52:14 +0000 |
commit | 8509c106effa0bcb10e519c9893d161258ddd330 (patch) | |
tree | 5127940f781b156275945e15f7db6d4d66dffa8e /lib | |
parent | 986c9fbae8a9ae3f8ae3a66c6f09b777af127dfa (diff) | |
download | src-8509c106effa0bcb10e519c9893d161258ddd330.tar.gz src-8509c106effa0bcb10e519c9893d161258ddd330.zip |
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
Notes
Notes:
svn path=/head/; revision=126206
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 fcc54dc71dd3..3161fc37dcba 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; |