Permalink
Browse files

2007-06-05 Sebastien Pouliot <sebastien@ximian.com>

	* emfcodec.c, emfplus.c, metafile.h, wmfcodec.c, wmfcodec.h: ++ is 
	unsafe to use with the GUINTx_FROM_LE macro. Also avoid macro 
	re-declarations


svn path=/branches/mono-1-2-4/libgdiplus/; revision=78686
  • Loading branch information...
Sebastien Pouliot
Sebastien Pouliot committed Jun 5, 2007
1 parent 1c8f34f commit f9f593a57467a74fce0fd2fa990f208d0bdff7ae
Showing with 96 additions and 41 deletions.
  1. +6 −0 src/ChangeLog
  2. +52 −26 src/emfcodec.c
  3. +12 −6 src/emfplus.c
  4. +6 −0 src/metafile.h
  5. +20 −7 src/wmfcodec.c
  6. +0 −2 src/wmfcodec.h
View
@@ -1,3 +1,9 @@
+2007-06-05 Sebastien Pouliot <sebastien@ximian.com>
+
+ * emfcodec.c, emfplus.c, metafile.h, wmfcodec.c, wmfcodec.h: ++ is
+ unsafe to use with the GUINTx_FROM_LE macro. Also avoid macro
+ re-declarations
+
2007-05-03 Sebastien Pouliot <sebastien@ximian.com>
* print.c: Re-enable printing support.
View
@@ -110,13 +110,18 @@ PolyBezier (MetafilePlayContext *context, BYTE *data, int len, BOOL compact)
GpStatus status;
int p, n = 0;
RECTL bounds;
- bounds.left = GETDW(DWP(n++));
- bounds.top = GETDW(DWP(n++));
- bounds.right = GETDW(DWP(n++));
- bounds.bottom = GETDW(DWP(n++));
+ bounds.left = GETDW(DWP(n));
+ n++;
+ bounds.top = GETDW(DWP(n));
+ n++;
+ bounds.right = GETDW(DWP(n));
+ n++;
+ bounds.bottom = GETDW(DWP(n));
+ n++;
/* make sure we're not reading more data than what's available in this record */
- num = GETDW(DWP(n++));
+ num = GETDW(DWP(n));
+ n++;
if (compact) {
/* len = bounds (4 * DWORD) + num (DWORD) + 2 * num * (x WORD + y WORD) */
if (num > ((len - 5 * sizeof (DWORD)) >> 2))
@@ -148,12 +153,15 @@ PolyBezier (MetafilePlayContext *context, BYTE *data, int len, BOOL compact)
pt++;
for (p = 0; p < num; p++, pt++) {
if (compact) {
- DWORD xy = GETDW(DWP(n++));
+ DWORD xy = GETDW(DWP(n));
+ n++;
pt->X = (xy & 0x0000FFFF);
pt->Y = (xy >> 16);
} else {
- pt->X = GETDW(DWP(n++));
- pt->Y = GETDW(DWP(n++));
+ pt->X = GETDW(DWP(n));
+ n++;
+ pt->Y = GETDW(DWP(n));
+ n++;
}
#ifdef DEBUG_EMF_2
printf ("\n\tbezier to %g,%g", pt->X, pt->Y);
@@ -180,13 +188,18 @@ Polygon (MetafilePlayContext *context, BYTE *data, int len, BOOL compact)
GpStatus status;
int p, n = 0;
RECTL bounds;
- bounds.left = GETDW(DWP(n++));
- bounds.top = GETDW(DWP(n++));
- bounds.right = GETDW(DWP(n++));
- bounds.bottom = GETDW(DWP(n++));
+ bounds.left = GETDW(DWP(n));
+ n++;
+ bounds.top = GETDW(DWP(n));
+ n++;
+ bounds.right = GETDW(DWP(n));
+ n++;
+ bounds.bottom = GETDW(DWP(n));
+ n++;
/* make sure we're not reading more data than what's available in this record */
- num = GETDW(DWP(n++));
+ num = GETDW(DWP(n));
+ n++;
if (compact) {
/* len = bounds (4 * DWORD) + num (DWORD) + 2 * num * (x WORD + y WORD) */
if (num > ((len - 5 * sizeof (DWORD)) >> 2))
@@ -208,12 +221,15 @@ Polygon (MetafilePlayContext *context, BYTE *data, int len, BOOL compact)
for (p = 0, pt = points; p < num; p++, pt++) {
if (compact) {
- DWORD xy = GETDW(DWP(n++));
+ DWORD xy = GETDW(DWP(n));
+ n++;
pt->X = (xy & 0x0000FFFF);
pt->Y = (xy >> 16);
} else {
- pt->X = GETDW(DWP(n++));
- pt->Y = GETDW(DWP(n++));
+ pt->X = GETDW(DWP(n));
+ n++;
+ pt->Y = GETDW(DWP(n));
+ n++;
}
#ifdef DEBUG_EMF_2
printf ("\n\tpoly to %g,%g", pt->X, pt->Y);
@@ -234,16 +250,22 @@ PolyPolygon (MetafilePlayContext *context, BYTE *data, BOOL compact)
int poly_num;
int n = 0;
RECTL bounds;
- bounds.left = GETDW(DWP(n++));
- bounds.top = GETDW(DWP(n++));
- bounds.right = GETDW(DWP(n++));
- bounds.bottom = GETDW(DWP(n++));
+ bounds.left = GETDW(DWP(n));
+ n++;
+ bounds.top = GETDW(DWP(n));
+ n++;
+ bounds.right = GETDW(DWP(n));
+ n++;
+ bounds.bottom = GETDW(DWP(n));
+ n++;
/* variable number of polygons */
- poly_num = GETDW(DWP(n++));
+ poly_num = GETDW(DWP(n));
+ n++;
/* total number of points (in all polygons)*/
- int total = GETDW(DWP(n++));
+ int total = GETDW(DWP(n));
+ n++;
int i;
PointFList *list = GdipAlloc (poly_num * sizeof (PointFList));
PointFList *current = list;
@@ -253,7 +275,8 @@ PolyPolygon (MetafilePlayContext *context, BYTE *data, BOOL compact)
#endif
/* read size of each polygon and allocate the required memory */
for (i = 0; i < poly_num; i++) {
- current->num = GETDW(DWP(n++));
+ current->num = GETDW(DWP(n));
+ n++;
current->points = (GpPointF*) GdipAlloc (current->num * sizeof (GpPointF));
#ifdef DEBUG_EMF_2
printf ("\n\tSub Polygon #%d has %d points", i, current->num);
@@ -267,12 +290,15 @@ PolyPolygon (MetafilePlayContext *context, BYTE *data, BOOL compact)
int p;
for (p = 0; p < current->num; p++) {
if (compact) {
- DWORD xy = GETDW(DWP(n++));
+ DWORD xy = GETDW(DWP(n));
+ n++;
pt->X = (xy & 0x0000FFFF);
pt->Y = (xy >> 16);
} else {
- pt->X = GETDW(DWP(n++));
- pt->Y = GETDW(DWP(n++));
+ pt->X = GETDW(DWP(n));
+ n++;
+ pt->Y = GETDW(DWP(n));
+ n++;
}
#ifdef DEBUG_EMF_3
printf ("\n\t\tpoly to %g,%g", pt->X, pt->Y);
View
@@ -92,17 +92,23 @@ EmfPlusFillRects (MetafilePlayContext *context, WORD flags, BYTE* data, int size
while ((i++ < num) && (status == Ok)) {
float x, y, w, h;
if (use_int16) {
- DWORD xy = GETDW(DWP(n++));
+ DWORD xy = GETDW(DWP(n));
+ n++;
x = (xy >> 16);
y = (WORD)xy;
- DWORD wh = GETDW(DWP(n++));
+ DWORD wh = GETDW(DWP(n));
+ n++;
w = (wh >> 16);
h = (WORD)wh;
} else {
- x = (float) GETDW(DWP(n++));
- y = (float) GETDW(DWP(n++));
- w = (float) GETDW(DWP(n++));
- h = (float) GETDW(DWP(n++));
+ x = (float) GETDW(DWP(n));
+ n++;
+ y = (float) GETDW(DWP(n));
+ n++;
+ w = (float) GETDW(DWP(n));
+ n++;
+ h = (float) GETDW(DWP(n));
+ n++;
}
#ifdef DEBUG_EMFPLUS_2
printf ("\n\t\t%d - x %g, y %g, w %g, h %g", i, x, y, w, h);
View
@@ -334,6 +334,12 @@ GpStatus GdipPlayMetafileRecord (GDIPCONST GpMetafile *metafile, EmfPlusRecordTy
#define gdip_get_metaheader(image) (&((GpMetafile*)image)->metafile_header)
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define GETDW(x) (*(DWORD*)(data + (x)))
+#else
+#define GETDW(x) (GUINT32_FROM_LE(*(DWORD*)(data + (x))))
+#endif
+
GpStatus gdip_get_metafile_from (void *pointer, GpMetafile **metafile, ImageSource source) GDIP_INTERNAL;
GpStatus gdip_metafile_clone (GpMetafile *metafile, GpMetafile **clonedmetafile) GDIP_INTERNAL;
GpStatus gdip_metafile_dispose (GpMetafile *metafile) GDIP_INTERNAL;
View
@@ -39,6 +39,12 @@ static const BYTE wmf_sig_mask[] = { 0xFF, 0xFF, 0xFF, 0xFF };
#define DEBUG_WMF_NOTIMPLEMENTED
#endif
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define GETW(x) (*(WORD*)(data + (x)))
+#else
+#define GETW(x) (GUINT16_FROM_LE(*(WORD*)(data + (x))))
+#endif
+
ImageCodecInfo*
gdip_getcodecinfo_wmf ()
{
@@ -117,8 +123,10 @@ Polygon (MetafilePlayContext *context, BYTE *data, int len)
int n = 2;
for (p = 0, pt = points; p < num; p++, pt++) {
- pt->X = GETW(WP(n++));
- pt->Y = GETW(WP(n++));
+ pt->X = GETW(WP(n));
+ n++;
+ pt->Y = GETW(WP(n));
+ n++;
#ifdef DEBUG_WMF
printf ("\n\tpoly to %g,%g", pt->X, pt->Y);
#endif
@@ -146,8 +154,10 @@ Polyline (MetafilePlayContext *context, BYTE *data)
SHORT y1 = GETW(WP3);
int n = 4;
for (p = 1; p < num; p++) {
- SHORT x2 = GETW(WP(n++));
- SHORT y2 = GETW(WP(n++));
+ SHORT x2 = GETW(WP(n));
+ n++;
+ SHORT y2 = GETW(WP(n));
+ n++;
#ifdef DEBUG_WMF_2
printf ("\n\tdraw from %d,%d to %d,%d", x1, y1, x2, y2);
#endif
@@ -179,7 +189,8 @@ PolyPolygon (MetafilePlayContext *context, BYTE *data)
int n = 2;
/* read size of each polygon and allocate the required memory */
for (i = 0; i < poly_num; i++) {
- current->num = GETW(WP(n++));
+ current->num = GETW(WP(n));
+ n++;
current->points = (GpPointF*) GdipAlloc (current->num * sizeof (GpPointF));
#ifdef DEBUG_WMF_2
printf ("\n\tSub Polygon #%d has %d points", i, current->num);
@@ -193,8 +204,10 @@ PolyPolygon (MetafilePlayContext *context, BYTE *data)
GpPointF *pt = current->points;
int p;
for (p = 0; p < current->num; p++) {
- pt->X = GETW(WP(n++));
- pt->Y = GETW(WP(n++));
+ pt->X = GETW(WP(n));
+ n++;
+ pt->Y = GETW(WP(n));
+ n++;
#ifdef DEBUG_WMF_3
printf ("\n\t\tpoly to %g,%g", pt->X, pt->Y);
#endif
View
@@ -35,8 +35,6 @@
if (params < (x)) goto cleanup; \
} while (0)
-#define GETDW(x) (*(DWORD*)(data + (x)))
-#define GETW(x) (*(WORD*)(data + (x)))
#define RECORDSIZE 0
#define FUNCTION 4
#define WP1 6

0 comments on commit f9f593a

Please sign in to comment.