INF: Overwriting End of HALLOC Causes Crash at Termination

ID Number: Q38294

5.00 5.10 6.00 6.00a 6.00ax 7.00 | 5.00 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

SYMPTOMS

In Microsoft C versions 5.0, 5.1, 6.0, 6.0a, 6.0ax, and C/C++

version 7.0, the following message may appear at the termination

of a program:

Memory allocation error: Cannot load command.com

CAUSE

The above error may be caused by overwriting past the end of a

block of memory allocated by halloc(). The bytes following a

halloc'd block are used by MS-DOS to track memory allocation, and

MS-DOS may be unable to load COMMAND.COM when your process is

completed if this area is corrupted.

Also, this error might be caused by overwriting blocks of memory

allocated by other functions such as calloc(), malloc(),

_fcalloc(), _fmalloc(), _ncalloc(), and _nmalloc().

RESOLUTION

Double-check your code to make sure you are not overwriting blocks

of memory allocated by the above mentioned functions.

Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax 7.00