Bugfix: must cast void* to do pointer math

Fixes #78.
This commit is contained in:
Paul Harris 2012-06-04 02:17:29 +08:00 committed by Petri Lehtinen
parent 2b87fdcb43
commit f62b1f5d69
1 changed files with 2 additions and 2 deletions

View File

@ -55,14 +55,14 @@ static void *secure_malloc(size_t size)
/* Store the memory area size in the beginning of the block */
void *ptr = malloc(size + 8);
*((size_t *)ptr) = size;
return ptr + 8;
return (char *)ptr + 8;
}
static void secure_free(void *ptr)
{
size_t size;
ptr -= 8;
ptr = (char *)ptr - 8;
size = *((size_t *)ptr);
/*guaranteed_*/memset(ptr, 0, size);