Memory Smashing

Memory Smashing - Memory Smashing Memory Smashing happens...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Memory Smashing Memory Smashing happens when less memory is allocated than the memory that will be used. This causes overwriting the header of the object that immediately follows, corrupting the free list. Subsequent calls to malloc/free may crash Sometimes the smashing happens in the unused portion of the object causing
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Memory Smashing Example: char * s = malloc(8); strcpy(s, “hello world”); // We are allocating less memory for // the string than the memory being // used. Strcpy will overwrite the // header and maybe next/prev of the // object that comes after s causing // future calls to malloc/free to crash. // Special care should be taken to also
Background image of page 2
Debugging Memory Allocation Errors Memory allocation errors are difficult to debug since the effect may happen farther away from the cause. Memory leaks is the least important of the problems since the effect take longer to show up.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

Memory Smashing - Memory Smashing Memory Smashing happens...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online