[Mono-dev] libgdiplus linecap issue

Francis A. Bausch fbausch at dracorp.com
Mon Oct 4 21:43:19 EDT 2010


unfortunately i was not carefui enough in my analysis.

this is my crash:

[Error, 10/4/2010, 9:21:22 PM] UNHANDLED EXCEPTION:
System.ArgumentException: A null reference or invalid value was found [GDI+ stat
us: InvalidParameter]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in <filename u
nknown>:0 
  at System.Drawing.Graphics.DrawPath (System.Drawing.Pen pen, System.Drawing.Dr
awing2D.GraphicsPath path) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Graphics:DrawPath (Syst
em.Drawing.Pen,System.Drawing.Drawing2D.GraphicsPath)


 the issue appears to be in the calculation of angle, in 
customlinecap.c::gdip_custom_linecap_angle (float x, float y, float otherend_x, float otherend_y)

double
gdip_custom_linecap_angle (float x, float y, float otherend_x, float otherend_y)
{
	float slope;
	double angle;
	
	if (y < otherend_y) {
		slope = (otherend_y - y) / (otherend_x - x);
		if (x < otherend_x) {
			angle = PI/2;
		} else {
			angle = PI/-2;
		}
	} else {
		slope = (otherend_x - x) / (y - otherend_y);
		angle = 0;
	}
	angle += atan (slope);

	return angle;
}


if otherend_x = x, or otherend_y=y, the calculation of slope may result in division by zero.


apologies for the hasty mis-analysis.

________________________________________
From: Francis A. Bausch
Sent: Monday, October 04, 2010 8:38 PM
To: mono-devel-list at lists.ximian.com
Subject: libgdiplus linecap issue

In the recent addition of linecaps to libgdiplus, an issue exists in the implementation of cairo_DrawPath in graphics-cairo.c.

A test on the value of count is needed to make sure array indices are valid at line 642:

gdip_pen_draw_custom_end_cap(graphics, pen, points[count-1].Y, points[count-2].X, points[count-2].Y, points[count-1].X)

it is obvious that count must be >= 2, but the functionality seems to require count > 2.



More information about the Mono-devel-list mailing list