What happens if you Call a free on a pointer twice?
Suppose that you have int *a = malloc (sizeof (int)) and a has 0xdeadbeef and you execute free (a) then after execution a still contains 0xdeadbeef but after the free call this memory address is no more reserved for you.
Something like you have rented a flat with malloc used for some time, returned the flat by free then you might have a duplicate key for the flat, but it is not reserved for you.
Doing a free on an already freed memory will result in double free memory corruption.
Callling-free-twice-on-pointer |
Answer Original Source: StackOverFlow
Other Articles:
Kth smallest element , Merge Point In LinkList, Compare two String Represented in Link-List
Article Sources For Learning
Other Blogs: Follow here
0 comments:
Post a Comment