PRC9108005: C 5.1 _rectangle() Function May Hang

ID Number: Q75322

5.10

MS-DOS

buglist5.10 fixlist6.00

Summary:

PROBLEM ID: PRC9108005

SYMPTOMS

In the Microsoft C Compiler version 5.1 and in the Microsoft QuickC

Compiler versions 1.0 and 1.01, if the function _rectangle() is

called with coordinates that are beyond the boundary for the current

graphics screen, the system will hang.

RESOLUTION/STATUS

To avoid the problem, make sure that the coordinates supplied to the

_rectangle() function lie within the proper boundary. Refer to the

documentation to find out what the boundary is for each video mode.

Microsoft has confirmed this to be a problem in C version 5.1 and in

QuickC versions 1.0 and 1.01 (buglist1.00, buglist1.01). The problem

was corrected in C version 6.0 and in QuickC version 2.0

(fixlist2.00).

More Information:

The following code demonstrates the problem. In C 5.1, the first

rectangle will be drawn, then the system hangs while attempting to

draw the second rectangle because the y-coordinates are out of

bounds. In C 6.0, the second call to _rectangle() will fail and the

appropriate message will be printed to the screen.

Sample Code

-----------

/* Compile options needed: none

*/

#include <graph.h>

#include <conio.h>

void main()

{

if(_setvideomode(_MRES16COLOR))

{

if(!(_rectangle( _GFILLINTERIOR, 80, 50, 240, 150)))

_outtext("Call to rectangle failed.\n");

getch();

_clearscreen( _GCLEARSCREEN );

if(!(_rectangle(_GFILLINTERIOR, 410, 420, 440, 440)))

_outtext("Call to rectangle failed.\n");

getch();

}

else

{

_outtext( "Unsupported video mode.\n" );

}

_setvideomode( _DEFAULTMODE );

}

Additional reference words: 1.00 2.00 5.10 6.00