Commit 600f507c authored by Raph Levien's avatar Raph Levien

Fixed uninitialized memory reads brought to my attention by Morten

Welinder. Thanks Morten!
parent 8e4d5e12
Fri Apr 14 16:33:55 2000 Raph Levien <raph@acm.org>
* art_svp_wind.c (art_svp_uncross, art_svp_rewind_uncrossed):
Fixed uninitialized memory reads when inserting new segment into
active_segs.
* art_bpath.c (art_bpath_affine_transform): Made it avoid
potential uninitialized memory reads when not all the coordinates
are needed. Thanks to Morten Welinder for spotting both of these
problems.
2000-04-05 Raph Levien <raph@gimp.org>
* art_svp_wind.c: Make "colinear" warnings go to stderr instead
......
......@@ -44,6 +44,7 @@ art_bpath_affine_transform (const ArtBpath *src, const double matrix[6])
int i;
int size;
ArtBpath *new;
ArtPathcode code;
double x, y;
for (i = 0; src[i].code != ART_END; i++);
......@@ -53,21 +54,38 @@ art_bpath_affine_transform (const ArtBpath *src, const double matrix[6])
for (i = 0; i < size; i++)
{
new[i].code = src[i].code;
x = src[i].x1;
y = src[i].y1;
new[i].x1 = matrix[0] * x + matrix[2] * y + matrix[4];
new[i].y1 = matrix[1] * x + matrix[3] * y + matrix[5];
x = src[i].x2;
y = src[i].y2;
new[i].x2 = matrix[0] * x + matrix[2] * y + matrix[4];
new[i].y2 = matrix[1] * x + matrix[3] * y + matrix[5];
code = src[i].code;
new[i].code = code;
if (code == ART_CURVETO)
{
x = src[i].x1;
y = src[i].y1;
new[i].x1 = matrix[0] * x + matrix[2] * y + matrix[4];
new[i].y1 = matrix[1] * x + matrix[3] * y + matrix[5];
x = src[i].x2;
y = src[i].y2;
new[i].x2 = matrix[0] * x + matrix[2] * y + matrix[4];
new[i].y2 = matrix[1] * x + matrix[3] * y + matrix[5];
}
else
{
new[i].x1 = 0;
new[i].y1 = 0;
new[i].x2 = 0;
new[i].y2 = 0;
}
x = src[i].x3;
y = src[i].y3;
new[i].x3 = matrix[0] * x + matrix[2] * y + matrix[4];
new[i].y3 = matrix[1] * x + matrix[3] * y + matrix[5];
}
new[i].code = ART_END;
new[i].x1 = 0;
new[i].y1 = 0;
new[i].x2 = 0;
new[i].y2 = 0;
new[i].x3 = 0;
new[i].y3 = 0;
return new;
}
......
......@@ -1092,12 +1092,13 @@ art_svp_uncross (ArtSVP *vp)
seg_map[seg_idx] = seg_num;
tmp1 = seg_idx;
for (j = i; j <= n_active_segs; j++)
for (j = i; j < n_active_segs; j++)
{
tmp2 = active_segs[j];
active_segs[j] = tmp1;
tmp1 = tmp2;
}
active_segs[n_active_segs] = tmp1;
n_active_segs++;
if (i > 0)
......@@ -1465,12 +1466,13 @@ art_svp_rewind_uncrossed (ArtSVP *vp, ArtWindRule rule)
}
tmp1 = seg_idx;
for (j = i; j <= n_active_segs; j++)
for (j = i; j < n_active_segs; j++)
{
tmp2 = active_segs[j];
active_segs[j] = tmp1;
tmp1 = tmp2;
}
active_segs[n_active_segs] = tmp1;
n_active_segs++;
seg_idx++;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment