From a8135829fff2b8ce3ed90e60401a09a6f3483621 Mon Sep 17 00:00:00 2001 From: grehan Date: Wed, 25 Feb 2004 00:52:14 +0000 Subject: 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 --- lib/libstand/zalloc_malloc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib') 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; -- cgit v1.1