File: 33_sanitize_rect.patch

package info (click to toggle)
fig2dev 1%3A3.2.8b-3%2Bdeb12u2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,008 kB
  • sloc: ansic: 37,618; sh: 7,021; makefile: 175; csh: 12
file content (51 lines) | stat: -rw-r--r-- 1,781 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From: Thomas Loimer <thomas.loimer@tuwien.ac.at>
Date: Sun, 1 May 2022 20:08:16 +0200
Origin: upstream, https://sourceforge.net/p/mcj/fig2dev/ci/6678ad8
Bug: https://sourceforge.net/p/mcj/tickets/142/
Subject: Sanitize rectangles with less than 4 corners, #142
 Box objects, e.g., rectangles, were closed and probably further sanitized,
 regardless of the number of points. Only close boxes, and probably sanitize
 them further, if they have at least four points. A NULL pointer dereference
 was triggered for the gbx output language, ticket [#142].

--- a/fig2dev/read.c
+++ b/fig2dev/read.c
@@ -916,6 +916,8 @@ sanitize_lineobject(
 
 	if ((l->type == T_BOX || l->type == T_POLYGON ||
 			l->type == T_ARC_BOX || l->type == T_PIC_BOX) &&
+		l->points->next && l->points->next->next &&
+		l->points->next->next->next &&
 		(l->points->x != p->x || l->points->y != p->y)) {
 	    /* tests/testsuite -k open,read.c */
 	    put_msg("An open %s at line %d - close it.",
--- a/fig2dev/tests/read.at
+++ b/fig2dev/tests/read.at
@@ -83,8 +83,7 @@ FIG_FILE_TOP
 2 2 0 1 -1 -1 50 -1 -1 0.000 0 0 -1 0 0 3
 	 0 10200 1200 9225 0 9225
 EOF
-],0,ignore,[An open rectangle at line 11 - close it.
-A rectangle with 3 corners at line 11 - convert to a polygon.
+],0,ignore,[A rectangle with 2 corners at line 11 - convert to a polygon.
 ])
 AT_CLEANUP
 
@@ -99,6 +98,17 @@ EOF
 ])
 AT_CLEANUP
 
+AT_SETUP([convert box with two points to a polyline, #142])
+AT_KEYWORDS(read.c gbx)
+AT_CHECK([fig2dev -L gbx <<EOF
+FIG_FILE_TOP
+2 2 0 1 -1 -1 50 -1 -1 0.0 1 0 -1 0 0 2
+	 0 0 0 600
+EOF
+],0,ignore,[A rectangle with 2 points at line 11 - convert to a polyline.
+])
+AT_CLEANUP
+
 AT_SETUP([fail on a malformed arc-box])
 AT_KEYWORDS(read.c malformed arc-box)
 AT_CHECK([fig2dev -L pict2e <<EOF