Exploit more memory than allocated with malloc(), why?

  • datatype *variable_name = (datatype*)malloc(no._of_elements*sizeof(datatype))
  • free(variable_name)
  • Those bytes may belong to other bits of your program, which will cause problems later in the execution.
  • Or, they might NOT belong to your program, which will result in an immediate segmentation fault.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store