Questions tagged [dangling-pointer]

Dangling pointers and wild pointers in computer programming are pointers that do not point to a valid object of the appropriate type.

Dangling pointers and wild pointers in computer programming are pointers that do not point to a valid object of the appropriate type. These are special cases of memory safety violations.

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.

Source: http://en.wikipedia.org/wiki/Dangling_pointer

167 questions
-3
votes
8 answers

Why is assigning 0 to a pointer a solution to a dangling pointer?

What does the OS/Debugger do when a pointer is assigned 0?
unj2
  • 52,135
  • 87
  • 247
  • 375
-4
votes
1 answer

Dangling pointer and segmentation fault

Here is an example code: class IntWrapper { public: IntWrapper(int value_ = 0): value(value_) {} int getNumber() { return value; } void setNumber(int value_) { value = value_; } private: int value; }; class…
Irbis
  • 11,537
  • 6
  • 39
  • 68
1 2 3
11
12