Skip to content
Browse files

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

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


svn path=/trunk/libgdiplus/; revision=78678
  • Loading branch information...
1 parent a89f39b commit 4133fea9db8959ab9fd5a5638e4ec65f7d811773 Sebastien Pouliot committed Jun 5, 2007
Showing with 83 additions and 35 deletions.
  1. +5 −0 src/ChangeLog
  2. +52 −26 src/emfcodec.c
  3. +6 −0 src/metafile-private.h
  4. +20 −7 src/wmfcodec.c
  5. +0 −2 src/wmfcodec.h
View
5 src/ChangeLog
@@ -1,3 +1,8 @@
+2007-06-05 Sebastien Pouliot <sebastien@ximian.com>
+
+ * emfcodec.c, metafile-private.h, wmfcodec.c, wmfcodec.h: ++ is unsafe
+ to use with the GUINTx_FROM_LE macro. Also avoid macro re-declarations
+
2007-05-30 Sebastien Pouliot <sebastien@ximian.com>
* gifcodec.c: Add support for interlaced GIF. Fix bug #81773
View
78 src/emfcodec.c
@@ -112,13 +112,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))
@@ -150,12 +155,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);
@@ -182,13 +190,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))
@@ -210,12 +223,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);
@@ -236,16 +252,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;
@@ -255,7 +277,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);
@@ -269,12 +292,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
6 src/metafile-private.h
@@ -60,6 +60,12 @@
#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
+
typedef struct {
void *ptr;
int type;
View
27 src/wmfcodec.c
@@ -92,6 +92,12 @@ GetColor (WORD w1, WORD w2)
return color;
}
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define GETW(x) (*(WORD*)(data + (x)))
+#else
+#define GETW(x) (GUINT16_FROM_LE(*(WORD*)(data + (x))))
+#endif
+
#define GetParam(x,y) GetWORD((6 + ((x) << 1)), (y))
@@ -118,8 +124,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
@@ -147,8 +155,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
@@ -180,7 +190,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);
@@ -194,8 +205,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
2 src/wmfcodec.h
@@ -33,8 +33,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 4133fea

Please sign in to comment.
Something went wrong with that request. Please try again.