Click here to Skip to main content
13,352,280 members (75,085 online)
Click here to Skip to main content


61 bookmarked
Posted 4 May 2012

Dangling Pointers: Pathology, Prevention and Cure

, 11 Nov 2012
Dangling pointers were a problem in the past, but nowadays we'll find none, right? Guess again...
pX (a.k.a pI) is alive; the size of X is 16 bytes; the int takes 4, the double 8, and the vtable pointer 4.
I::foo address is 00401030
pI->foo(3, 5.050000) = 15.150000
Not crashed yet: pX->a is 1 (0x1), pX->y is 2.000000e+000 (0x4000000000000000)
Still not crashed; pX->y is 111.222333
X::foo address is 00401030
pX->multiply() returned 222.444666. Are we crashing yet?
pX is UNDEAD!.

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Pablo Aliskevicius
Software Developer (Senior)
Israel Israel
Pablo writes code for a living, in C++, C#, and SQL.

To make all that work easier, he uses some C++ libraries: STL, ATL & WTL (to write Windows applications), and code generation.

Pablo was born in 1963, got married in 1998, and is the proud father of two wonderful girls.

Favorite quotes:
"Accident: An inevitable occurrence due to the action of immutable natural laws." (Ambrose Bierce, "The Devil's Dictionary", published in several newspapers between 1881 and 1906).
"You are to act in the light of experience as guided by intelligence" (Rex Stout, "In the Best Families", 1950).

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180111.1 | Last Updated 11 Nov 2012
Article Copyright 2012 by Pablo Aliskevicius
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid