Delphi / Object Pascal · Exception

Runtime Error 204: EInvalidPointer

What does Runtime Error 204: EInvalidPointer mean in Delphi / Object Pascal?

An operation on a pointer is invalid, most often a double free (calling Free twice on the same object) or freeing memory that was never validly allocated.

Runtime Error 204: EInvalidPointerDelphi (VCL) · Delphi (FireMonkey)

Condition

An operation on a pointer is invalid, most often a double free (calling Free twice on the same object) or freeing memory that was never validly allocated.

Fix

Set object references to nil immediately after freeing them, and consider FreeAndNil instead of a bare Free call so a second Free on the same variable becomes a harmless no-op instead of a crash.

Pending source verification. Not yet checked against official documentation.

Related exception