A dangling pointer is a flaw in object-oriented coding where a pointer object points to a non-existent object. This creates subtle bugs and security risks. Deleting the pointer instance solves the problem. Dangling pointers can cause quality issues and hackers can exploit them. They may not be detected for months or years.
A dangling pointer is a programming flaw that occurs in object-oriented coding when a pointer object points to another object that no longer exists. In this case, a pointer is not a mouse pointer, but a pointer object that is intended to send the user to another object. This flaw creates subtle bugs that can get worse with time, and also presents a security flaw that experienced hackers can attack. A dangling pointer occurs when a programmer deletes the object pointed to but does not delete the pointer itself.
In object-oriented coding, where the coding is separated into objects, there is an instance called a pointer. The pointer instance is placed somewhere in the program, usually in a menu, and takes the user to another object. For example, if the user highlights a section of a menu, another menu appears, a drop-down menu. This allows the programmer to set up multiple objects in a section without crowding the section.
The hanging pointer error occurs when a programmer deletes the pointed object. If the programmer also deletes the pointer instance, there will be no problem. If the programmer forgets and keeps the pointer in the encoding, this creates a dangling pointer and has quality and security issues.
In terms of quality, a dangling pointer looks sloppy and creates subtle bugs. This is because the program doesn’t know how to act, because it is told to do something but can’t because the object is no longer there. This act creates random code or degrades code in small, subtle ways that are difficult to detect. These bugs can be so small that they make your program run a little slower, but they could eventually make your program, and even your computer, not work.
Most programs with dangling pointers will work initially and may continue to work for months or even years before the errors become apparent. Even programs that do calculations, meaning the dangling pointer is in the formula, may still be able to do simple calculations. This is one reason why finding dangling pointers can be so difficult.
Until 2007, the dangling pointer only created security problems in theory. Software company Watchfire® then built a program that showed how to exploit dangling pointers, making the security risk a reality. Hackers are able to infiltrate a program via this bug and can inject their own code into the faulty program.
Protect your devices with Threat Protection by NordVPN