Pointer with a possible value NULL is used like it always points to a valid memory area:
#include <stddef.h>
int *p = NULL;
*p;
Trying to use a null pointer *p will cause undefined behaviour, depending on compiler and operating system. Reading from it might return garbage values, writing to it might corrupt memory somewhere else. Null pointer errors have also been used to go around security systems. Protected mode OSes usually stop the application trying to do such things, causing application to crash instead of the OS.How to fix: check pointer value before trying to use it. Code safe.
No comments:
Post a Comment