What is Dangling pointer?

A pointer that still points to a region whose lifetime has ended. Typical cases are a pointer after the memory was released with free, and a pointer to a local variable after the function has returned. Reading or writing through it (use after free) or freeing it again (double free) is undefined behavior, and may appear to work for a while before causing hard-to-trace failures elsewhere. It is prevented by assigning NULL after free and by not returning the address of a local variable from a function, among other measures.

Japanese name: ダングリングポインタ

Dangling pointer appears in 1 practice question across 1 topic, including C Programming Basics.

Field: C Programming Basics

Dangling pointer in the explanations

Questions that mention Dangling pointer (1)

  1. Which of the following is true about the pointer returned by the function make above?

Books on C Programming Basics Ad

As an Amazon Associate I earn from qualifying purchases.

Related terms

Pointer Variable Stack Undefined behavior Dynamic memory allocation Alignment and padding Bit-field Buffer overflow Function pointer Integer promotion

Back to the glossary