Ask a Question

what is dangling pointer?

on 2010-09-30 01:40:27   by Prasun   on Computer Science & Engineering  2 answers

Arpan

on 2010-09-29 09:30:00  

A pointer pointing to memory address which don\'t exist anymore in heap.

Administrator

on 2010-09-30 09:30:00  

Dangling pointers and wild pointers in computer programming are pointers that do not point to a valid object of the appropriate type. Dangling pointers arise when an object is deleted or deallocated, without modifying the value of the pointer, so that the pointer still points to the memory location of the deallocated memory. As the system may reallocate the previously freed memory to another process, if the original program then dereferences the (now) dangling pointer, unpredictable behavior may result, as the memory may now contain completely different data. This is especially the case if the program writes data to memory pointed by a dangling pointer, a silent corruption of unrelated data may result, leading to subtle bugs that can be extremely difficult to find, or cause segmentation faults (*NIX) or general protection faults (Windows). If the overwritten data is bookkeeping data used by the system\'s memory allocator, the corruption can cause system instabilities.