File 186.patch of Package transfig.38710
From c8a87d22036e62bac0c6f7836078d8103caa6457 Mon Sep 17 00:00:00 2001
From: Thomas Loimer <thomas.loimer@tuwien.ac.at>
Date: Wed, 22 Jan 2025 23:27:43 +0100
Subject: [PATCH] Reject arcs with co-incident points, ticket #186
---
fig2dev/object.h | 14 +++++++++-----
fig2dev/tests/read.at | 10 ++++++++++
2 files changed, 19 insertions(+), 5 deletions(-)
--- fig2dev/object.h
+++ fig2dev/object.h 2025-04-29 11:58:54.335653487 +0000
@@ -92,10 +92,10 @@ typedef struct f_ellipse {
struct f_ellipse *next;
} F_ellipse;
-#define INVALID_ELLIPSE(e) \
+#define INVALID_ELLIPSE(e) \
e->type < T_ELLIPSE_BY_RAD || e->type > T_CIRCLE_BY_DIA || \
- COMMON_PROPERTIES(e) || (e->direction != 1 && e->direction != 0) || \
- e->radiuses.x == 0 || e->radiuses.y == 0 || \
+ COMMON_PROPERTIES(e) || (e->direction != 1 && e->direction != 0) || \
+ e->radiuses.x == 0 || e->radiuses.y == 0 || \
e->angle < -7. || e->angle > 7.
typedef struct f_arc {
@@ -122,12 +122,16 @@ typedef struct f_arc {
struct f_arc *next;
} F_arc;
-#define INVALID_ARC(a) \
+#define COINCIDENT(a, b) (a.x == b.x && a.y == b.y)
+#define INVALID_ARC(a) \
a->type < T_OPEN_ARC || a->type > T_PIE_WEDGE_ARC || \
COMMON_PROPERTIES(a) || a->cap_style < 0 || a->cap_style > 2 || \
a->center.x < COORD_MIN || a->center.x > COORD_MAX || \
a->center.y < COORD_MIN || a->center.y > COORD_MAX || \
- (a->direction != 0 && a->direction != 1)
+ (a->direction != 0 && a->direction != 1) || \
+ COINCIDENT(a->point[0], a->point[1]) || \
+ COINCIDENT(a->point[0], a->point[2]) || \
+ COINCIDENT(a->point[1], a->point[2])
typedef struct f_line {
int type;
--- fig2dev/tests/read.at
+++ fig2dev/tests/read.at 2025-04-29 11:58:54.335653487 +0000
@@ -213,6 +213,16 @@ EOF
])
AT_CLEANUP
+AT_SETUP([reject arcs with coincident points, ticket #186])
+AT_KEYWORDS(read.c arc)
+AT_CHECK([fig2dev -L pict2e <<EOF
+FIG_FILE_TOP
+5 1 0 15 0 7 50 0 -1 0.0 1 0 0 0 0.0 0.0 1 1 1 1 2 0
+EOF
+], 1, ignore, [Invalid arc object at line 10.
+])
+AT_CLEANUP
+
AT_SETUP([survive debian bugs #881143, #881144])
AT_KEYWORDS([font pic tikz])
AT_CHECK([fig2dev -L pic <<EOF