-secure_malloc [Professional Edition only] [V2.05.00 or later] |
< Library Generator Options / Library Options >
This option creates the calloc, free, malloc, and realloc functions to which a security facility for detecting illegal operations to storage areas has been added.
When one of the following operations is performed, the __heap_chk_fail function is called.
The pointer to an area other than that allocated by calloc, malloc, or realloc is passed to free or realloc. |
A value is written to up to four bytes before and after the area allocated by calloc, malloc, or realloc and the pointer to that area is passed to free or realloc. |
The same facility is also added to the new and delete operators in C++ programs.
The __heap_chk_fail function needs to be defined by the user and it describes the processing to be executed when an error occurs in management of dynamic memory.
Note the following points when defining the __heap_chk_fail function.
The only possible type of return value is void and the __heap_chk_fail function does not have formal parameters. |
The calloc, malloc, and realloc functions for the security facility secure four extra bytes before and after each allocated area for the purpose of detecting writing to addresses outside the allocated area. This consumes more heap memory area than with the usual functions. Using the new operators in C++ programs will also consume more heap memory area.