...
Wiki Markup |
---|
This example from Kernighan and Ritchie \[[Kernighan 88|AA. References#KernighanBibliography#Kernighan 88]\] shows both the incorrect and correct techniques for removing items from a linked list. The incorrect solution, clearly marked as wrong in the book, is bad because {{p}} is deallocated before the {{p->next}} is executed, so {{p->next}} reads memory that has already been deallocated. |
...
Wiki Markup |
---|
\[[Henricson 97|AA. References#HenricsonBibliography#Henricson 97]\] Rule 8.3 Do not access a pointer or reference to a deleted object \[[ISO/IEC 9899:1999|AA. References#ISOBibliography#ISO/IEC 9899-1999]\] Section 7.20.3.2, "The {{free}} function" \[[ISO/IEC PDTR 24772|AA. References#ISOBibliography#ISO/IEC PDTR 24772]\] "DCM Dangling references to stack frames" and "XYK Dangling Reference to Heap" \[[Kernighan 88|AA. References#KernighanBibliography#Kernighan 88]\] Section 7.8.5, "Storage Management" \[[MISRA 04|AA. References#MISRABibliography#MISRA 04]\] Rule 17.6 \[[MITRE 07|AA. References#MITREBibliography#MITRE 07]\] [CWE ID 416|http://cwe.mitre.org/data/definitions/416.html], "Use After Free" \[[OWASP Freed Memory|AA. References#OWASPBibliography#OWASP Freed Memory]\] \[[Seacord 05a|AA. References#SeacordBibliography#Seacord 05]\] Chapter 4, "Dynamic Memory Management" \[[Viega 05|AA. References#ViegaBibliography#Viega 05]\] Section 5.2.19, "Using freed memory" |
...