TOC | Prev | Next

Using more memory than you allocated

If you overwrite more memory than you allocated, you crash, or
corrupt memory, or open yourself to a security hole. (a/k/a "buffer
overflow")

char *p = malloc( 10 );
strcpy( p, "Hello, world!" );

or

char *p = malloc(10);
p[10] = 'x'; /* Off-by-one, a fencepost error */
TOC | Prev | Next