ID Number: Q64561
6.00
MS-DOS
buglist6.00 fixlist6.00a
Summary:
In Microsoft C version 6.0 large and compact memory models, _outtext()
can corrupt the string of characters passed to it in certain
circumstances. It does this by inserting a NULL character into the
string.
More Information:
The following program demonstrates the problem. Before the second
_outtext() call, the buffer is a full 2999 bytes; after the call, it
is considerably smaller, signifying that the NULL has been inserted
into the buffer.
Sample Code
-----------
/* Compile options needed: /AL
*/
#include<stdio.h>
#include<graph.h>
#include<memory.h>
#include<string.h>
#include<conio.h>
#include<process.h>
char buffer[3000];
void main(void)
{
memset(buffer,'A',3000);
buffer[2999]='\0';
printf("%d",strlen(buffer));
_settextrows(_MAXTEXTROWS);
_outtext((char far *)buffer); // Looks good so far.
getch();
printf("%d",strlen(buffer)); // String still not corrupted.
getch();
_outtext((char far *)buffer); // NULL inserted in buffer!
printf("%d",strlen(buffer)); // Notice smaller string length.
}
Microsoft has confirmed this to be a problem in C version 6.0. This
problem was corrected in C version 6.0a.
Additional reference words: s_quickc 6.00