mem: Add magic field to detect memory corruption
authorMatt Fleming <matt.fleming@intel.com>
Thu, 17 Jan 2013 14:33:25 +0000 (14:33 +0000)
committerMatt Fleming <matt.fleming@intel.com>
Thu, 21 Feb 2013 12:55:10 +0000 (12:55 +0000)
commit07395d946e566263525f08f31692678422976a21
tree56e5cf30b9cbcdf75d7e1a3b7ed62186bbbd69fb
parentb208ba467f678ed8e73f8d11fc0609634120cb83
mem: Add magic field to detect memory corruption

Very little checking is performed on the validity of freelist
metadata. Add a magic field to struct arena_header which can be used
to detect memory corruption or whether a user tries to free something
that isn't a malloc pointer.

This feature can be enabled with -DDEBUG_MALLOC. Turn it on for
development in mk/devel.mk.

Cc: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
core/mem/free.c
core/mem/init.c
core/mem/malloc.c
core/mem/malloc.h
dos/free.c
mk/devel.mk