add an infinite loop detector
This commit is contained in:
		
							parent
							
								
									2b9853fd4c
								
							
						
					
					
						commit
						eee409d4e7
					
				@ -29,6 +29,7 @@ static BOOL line_clip(PINT32 output, INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT
 | 
			
		||||
{
 | 
			
		||||
  BYTE outcode1, outcode2;
 | 
			
		||||
  INT32 tmp;
 | 
			
		||||
  int nloop = 0;
 | 
			
		||||
  
 | 
			
		||||
  Log(LDEBUG, "clipping line from (%d, %d) to (%d, %d) against bounding box (%d, %d, %d, %d)", x1 >> CPX, y1 >> CPX, x2 >> CPX, y2 >> CPX,
 | 
			
		||||
      xmin >> CPX, ymin >> CPX, xmax >> CPX, ymax >> CPX);
 | 
			
		||||
@ -36,6 +37,11 @@ static BOOL line_clip(PINT32 output, INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT
 | 
			
		||||
  /* Cohen-Sutherland line-clipping algorithm (see Foley & Van Dam, pp. 145-149) */
 | 
			
		||||
  for (;;)
 | 
			
		||||
  {
 | 
			
		||||
    if (++nloop == 20)
 | 
			
		||||
	{
 | 
			
		||||
	  Log(LDEBUG, "POSSIBLE INFINITE LOOP DETECTED - REJECTING");
 | 
			
		||||
	  return FALSE;
 | 
			
		||||
	}
 | 
			
		||||
    outcode1 = line_clip_outcode(x1, y1, xmin, ymin, xmax, ymax);
 | 
			
		||||
	outcode2 = line_clip_outcode(x2, y2, xmin, ymin, xmax, ymax);
 | 
			
		||||
	if ((outcode1 & outcode2) != 0)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user