FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

cairo terminals: ignore zero-size filled polygons · gnuplot/gnuplot@c0d44bb · GitHub

Repository navigation

Commit c0d44bb

Browse files
Ethan A Merritt
committed
cairo terminals: ignore zero-size filled polygons
Attempts to retrieve style information from the first vertex of a size zero polygon caused memory access errors.
1 parent 18272e0 commit c0d44bb

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

‎src/wxterminal/gp_cairo.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,9 @@ void gp_cairo_draw_polygon(plot_struct *plot, int n, gpiPoint *corners)
401401
/* begin by stroking any open path */
402402
gp_cairo_stroke(plot);
403403

404+
if (n <= 0)
405+
return;
406+
404407
if (plot->polygons_saturate) {
405408
int i;
406409
path_item *path;

‎term/cairo.trm‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,17 +1357,20 @@ void cairotrm_set_color(t_colorspec *colorspec)
13571357
/* here we send the polygon command */
13581358
void cairotrm_filled_polygon(int n, gpiPoint *corners)
13591359
{
1360-
gpiPoint *mirrored_corners = (gpiPoint*) gp_alloc(n*sizeof(gpiPoint),"mirrored_corners");
1360+
gpiPoint *corners_copy;
1361+
1362+
if (n <= 0)
1363+
return;
1364+
13611365
/* can't use memcpy() here, as we have to mirror the y axis */
1362-
gpiPoint *corners_copy = mirrored_corners;
1363-
while (corners_copy < (mirrored_corners + n)) {
1364-
*corners_copy = *corners++;
1365-
corners_copy->y = term->ymax - corners_copy->y;
1366-
++corners_copy;
1366+
corners_copy = gp_alloc(n*sizeof(gpiPoint),"mirrored_corners");
1367+
for (int i=0; i < n; i++) {
1368+
corners_copy[i] = corners[i];
1369+
corners_copy[i].y = term->ymax - corners_copy[i].y;
13671370
}
13681371

1369-
gp_cairo_draw_polygon(&plot, n, mirrored_corners);
1370-
free(mirrored_corners);
1372+
gp_cairo_draw_polygon(&plot, n, corners_copy);
1373+
free(corners_copy);
13711374
}
13721375

13731376
void cairotrm_image(unsigned int M, unsigned int N, coordval * image, gpiPoint * corner, t_imagecolor color_mode)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL