The information in this article applies to:
SYMPTOMS
Memory that is freed multiple times may cause an Application Error (AE).
CAUSEHeap control structures are modified after the first call to free() and no longer in a state where subsequent calls to free() will work. RESOLUTION
Avoid calling multiple free or multiple delete on the same pointer. One way
to prevent this is by assigning the pointer to null after calling free or
delete. The delete and free functions return without doing anything if a
null pointer is passed as the argument. This doesn't work in cases where
free or delete is called on multiple pointers pointing to the same memory
location. STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. Q194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why MORE INFORMATION
Freeing memory multiple times produces undefined behavior.
It is important to note that the state of the Small Block Heap (SBH) is constantly in flux. Because of this, there are situations where it's possible that no assertion will be issued in the debug build, but an application error will occur in the release build. Release builds in Visual C++ 6.0 are more sensitive to freeing memory multiple times than in Visual C++ 5.0. If built with Visual C++ 5.0, the case below is one where the incorrect call to free is innocuous. If the call to free() were made more distant from the original, it is possible to cause an application error. There is a high probability that memory will be corrupted. Sample code
Additional query words: msvcrt.dll kbVS600sp2
Keywords : kbcode kbservicepack kbCRT kbVC600 kbVS600sp2 kbVS600sp2bug kbVS600sp2fix kbVS600SP1 kbVS600sp3fix |
Last Reviewed: June 28, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |