The dynamic memory allocation mechanism is the target of many software security attacks. Through well-designed interactions with a vulnerable program to repeatedly request, release, or reference dynamically allocated memory, attackers can compromise the internal structure of a program and launch attacks. To prevent dynamically allocated memory from being accessed through the pointers that should be invalidated, we have designed a security mechanism, MallocList, to manage the pointers pointing to dynamically allocated memory. When a block of dynamically allocated memory is released, the corresponding content of the pointer is reset, and the original binding is invalidated. The use of the old pointer will not be linked to any memory location, it will prevent the problem of using the failed pointer to access new data. Our mechanism can be realized by modifying the dynamic memory allocation library. Executable code owners can benefit from the solution without needing to have access to the source code of vulnerable programs. A prototype of the proposed mechanism has been implemented and tested using known security attacks. Our experiment shows that the proposed mechanism can effectively defend against those types of attacks.