home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 14 Text / 14-Text.zip / C6_BUGS.ZIP / C6_20088.BUG < prev    next >
Text File  |  1990-09-11  |  1KB  |  56 lines

  1. Q64561 _outtext() Corrupts String in C 6.00 Large and Compact Models
  2. Microsoft C Compiler (C)
  3. 6.00
  4. MS-DOS
  5.  
  6. Summary:
  7.  
  8. In Microsoft C version 6.00 large and compact memory models,
  9. _outtext() can corrupt the string of characters passed to it in
  10. certain circumstances. It does this by inserting a NULL character into
  11. the string.
  12.  
  13. More Information:
  14.  
  15. The following program demonstrates the problem. Before the second
  16. _outtext() call, the buffer is a full 2999 bytes; after the call, it
  17. is considerably smaller, signifying that the NULL has been inserted
  18. into the buffer.
  19.  
  20. Sample Program
  21. --------------
  22.  
  23. #include<stdio.h>
  24. #include<graph.h>
  25. #include<memory.h>
  26. #include<string.h>
  27. #include<conio.h>
  28. #include<process.h>
  29.  
  30. char buffer[3000];
  31.  
  32. void main(void)
  33. {
  34.    memset(buffer,'A',3000);
  35.    buffer[2999]='\0';
  36.    printf("%d",strlen(buffer));
  37.    _settextrows(_MAXTEXTROWS);
  38.    _outtext((char far *)buffer);  // Looks good so far.
  39.  
  40.    getch();
  41.    printf("%d",strlen(buffer));   // String still not corrupted.
  42.  
  43.    getch();
  44.    _outtext((char far *)buffer);  // NULL inserted in buffer!
  45.    printf("%d",strlen(buffer));   // Notice smaller string length.
  46. }
  47.  
  48. Microsoft has confirmed this to be a problem with C version 6.00. We
  49. are researching this problem and will post new information here as it
  50. becomes available.
  51.  
  52. Keywords:  buglist6.00 s_quickc
  53.  
  54. COPYRIGHT Microsoft Corporation, 1990.
  55. Updated  90/09/01 08:26
  56.