Permalink
Browse files

2010-05-04 Miguel de Icaza <miguel@novell.com>

	* Apply patch from Matthew Metnetsky which fixes Bug #590286
	Passing -1 (to indicate null terminated string) for the string
	lengths for GdipDrawString and GdipMeasureString causes the
	program to seg-fault.

svn path=/trunk/libgdiplus/; revision=156698
  • Loading branch information...
migueldeicaza committed May 5, 2010
1 parent 3071749 commit 7c69f83c874e9d178b54f7ecb946926b1163a88f
Showing with 27 additions and 1 deletion.
  1. +7 −0 src/ChangeLog
  2. +20 −1 src/text.c
View
@@ -1,3 +1,10 @@
+2010-05-04 Miguel de Icaza <miguel@novell.com>
+
+ * Apply patch from Matthew Metnetsky which fixes Bug #590286
+ Passing -1 (to indicate null terminated string) for the string
+ lengths for GdipDrawString and GdipMeasureString causes the
+ program to seg-fault.
+
2010-04-12 Sebastien Pouliot <sebastien@ximian.com>
* pngcodec.c: SuSE provided patch for newer libpng (1.4.x). Made
View
@@ -43,8 +43,18 @@ GpStatus
GdipDrawString (GpGraphics *graphics, GDIPCONST WCHAR *string, int length, GDIPCONST GpFont *font, GDIPCONST RectF *layoutRect,
GDIPCONST GpStringFormat *stringFormat, GpBrush *brush)
{
- if (length == 0)
+ GDIPCONST WCHAR *ptr = NULL;
+
+ if (length == 0) {
return Ok;
+ } else if (length == -1) {
+ ptr = string;
+ length = 0;
+ while (*ptr != 0) {
+ length++;
+ ptr++;
+ }
+ }
if (!graphics || !string || !font || !layoutRect)
return InvalidParameter;
@@ -63,6 +73,8 @@ GpStatus
GdipMeasureString (GpGraphics *graphics, GDIPCONST WCHAR *string, int length, GDIPCONST GpFont *font, GDIPCONST RectF *layoutRect,
GDIPCONST GpStringFormat *stringFormat, RectF *boundingBox, int *codepointsFitted, int *linesFilled)
{
+ GDIPCONST WCHAR *ptr = NULL;
+
if (length == 0) {
if (boundingBox) {
if (layoutRect) {
@@ -82,6 +94,13 @@ GdipMeasureString (GpGraphics *graphics, GDIPCONST WCHAR *string, int length, GD
*codepointsFitted = 0;
}
return Ok;
+ } else if (length == -1) {
+ ptr = string;
+ length = 0;
+ while (*ptr != 0) {
+ length++;
+ ptr++;
+ }
}
if (!graphics || !string || !font || !layoutRect)

0 comments on commit 7c69f83

Please sign in to comment.