Patent ID: 7861231

Claim:
A method for dynamic identification of dangling pointer, the method comprises: segmenting a main memory preferably into three parts comprising (i) a first memory configured to store an object, the object is a respective stack and/or a respective heap; (ii) a version segment configured to store a version of a memory location in the first memory, the version initialized to a value zero; (iii) a pointer version segment configured to store a version of the pointer associated with the memory location in the first memory, the pointer version initialized to a negative value; and indicating reference to a dangling pointer on negative determination of the pointer version with the version on dereferencing a pointer in the first memory; further comprising: allocating a memory segment from the first memory for the object; creating a pointer for the object in the first memory segment; storing the pointer comprising an address of the object in the first memory segment; and assigning the version in the version segment associated with an object in the first memory to the pointer version in the pointer version segment associated with the pointer in the first memory; wherein when a pointer in the first memory is dereferenced comparing the pointer version associated with the pointer in the first memory against the version in the version segment for the object referred by the pointer in the first memory, and concluding that the pointer in the first memory is a dangling pointer when the comparison fails to yield a match.