Merge pull request #16 from dangowrt/wayland-stack
[feed/video.git] / libs / cairo / patches / 006-cff-allow-empty-array-of-operands-for-certain-operat.patch
1 From ef959bc76e65ea0b0d4ba3ee50dfbce31c3484ad Mon Sep 17 00:00:00 2001
2 From: Marek Kasik <mkasik@redhat.com>
3 Date: Fri, 27 Mar 2020 19:39:46 +0100
4 Subject: [PATCH] cff: Allow empty array of operands for certain operators
5
6 Operators BlueValues, OtherBlues, FamilyBlues, FamilyOtherBlues,
7 StemSnapH and StemSnapV have operands of type delta which can be
8 a number or an array of delta-encoded numbers. This array can be
9 empty according to freetype developers.
10 This commit checks whether current operator is among those listed
11 and permits empty operand in such case.
12 ---
13 src/cairo-cff-subset.c | 78 ++++++++++++++++++++++++++----------------
14 1 file changed, 49 insertions(+), 29 deletions(-)
15
16 Patch-Source: https://src.fedoraproject.org/rpms/cairo/blob/ba42ecc23bb1162a1951edc0209f9f48e87bba7e/f/0001-cff-Allow-empty-array-of-operands-for-certain-operat.patch
17 See-Also: https://bugzilla.redhat.com/show_bug.cgi?id=1817958
18
19 --- a/src/cairo-cff-subset.c
20 +++ b/src/cairo-cff-subset.c
21 @@ -56,30 +56,36 @@
22
23 /* CFF Dict Operators. If the high byte is 0 the command is encoded
24 * with a single byte. */
25 -#define BASEFONTNAME_OP 0x0c16
26 -#define CIDCOUNT_OP 0x0c22
27 -#define CHARSET_OP 0x000f
28 -#define CHARSTRINGS_OP 0x0011
29 -#define COPYRIGHT_OP 0x0c00
30 -#define DEFAULTWIDTH_OP 0x0014
31 -#define ENCODING_OP 0x0010
32 -#define FAMILYNAME_OP 0x0003
33 -#define FDARRAY_OP 0x0c24
34 -#define FDSELECT_OP 0x0c25
35 -#define FONTBBOX_OP 0x0005
36 -#define FONTMATRIX_OP 0x0c07
37 -#define FONTNAME_OP 0x0c26
38 -#define FULLNAME_OP 0x0002
39 -#define LOCAL_SUB_OP 0x0013
40 -#define NOMINALWIDTH_OP 0x0015
41 -#define NOTICE_OP 0x0001
42 -#define POSTSCRIPT_OP 0x0c15
43 -#define PRIVATE_OP 0x0012
44 -#define ROS_OP 0x0c1e
45 -#define UNIQUEID_OP 0x000d
46 -#define VERSION_OP 0x0000
47 -#define WEIGHT_OP 0x0004
48 -#define XUID_OP 0x000e
49 +#define BASEFONTNAME_OP 0x0c16
50 +#define CIDCOUNT_OP 0x0c22
51 +#define CHARSET_OP 0x000f
52 +#define CHARSTRINGS_OP 0x0011
53 +#define COPYRIGHT_OP 0x0c00
54 +#define DEFAULTWIDTH_OP 0x0014
55 +#define ENCODING_OP 0x0010
56 +#define FAMILYNAME_OP 0x0003
57 +#define FDARRAY_OP 0x0c24
58 +#define FDSELECT_OP 0x0c25
59 +#define FONTBBOX_OP 0x0005
60 +#define FONTMATRIX_OP 0x0c07
61 +#define FONTNAME_OP 0x0c26
62 +#define FULLNAME_OP 0x0002
63 +#define LOCAL_SUB_OP 0x0013
64 +#define NOMINALWIDTH_OP 0x0015
65 +#define NOTICE_OP 0x0001
66 +#define POSTSCRIPT_OP 0x0c15
67 +#define PRIVATE_OP 0x0012
68 +#define ROS_OP 0x0c1e
69 +#define UNIQUEID_OP 0x000d
70 +#define VERSION_OP 0x0000
71 +#define WEIGHT_OP 0x0004
72 +#define XUID_OP 0x000e
73 +#define BLUEVALUES_OP 0x0006
74 +#define OTHERBLUES_OP 0x0007
75 +#define FAMILYBLUES_OP 0x0008
76 +#define FAMILYOTHERBLUES_OP 0x0009
77 +#define STEMSNAPH_OP 0x0c0c
78 +#define STEMSNAPV_OP 0x0c0d
79
80 #define NUM_STD_STRINGS 391
81
82 @@ -615,13 +621,27 @@ cff_dict_create_operator (int
83 return _cairo_error (CAIRO_STATUS_NO_MEMORY);
84
85 _cairo_dict_init_key (op, operator);
86 - op->operand = _cairo_malloc (size);
87 - if (unlikely (op->operand == NULL)) {
88 - free (op);
89 - return _cairo_error (CAIRO_STATUS_NO_MEMORY);
90 + if (size != 0) {
91 + op->operand = _cairo_malloc (size);
92 + if (unlikely (op->operand == NULL)) {
93 + free (op);
94 + return _cairo_error (CAIRO_STATUS_NO_MEMORY);
95 + }
96 + memcpy (op->operand, operand, size);
97 + } else {
98 + op->operand = NULL;
99 + /* Delta-encoded arrays can be empty. */
100 + if (operator != BLUEVALUES_OP &&
101 + operator != OTHERBLUES_OP &&
102 + operator != FAMILYBLUES_OP &&
103 + operator != FAMILYOTHERBLUES_OP &&
104 + operator != STEMSNAPH_OP &&
105 + operator != STEMSNAPV_OP) {
106 + free (op);
107 + return _cairo_error (CAIRO_STATUS_NO_MEMORY);
108 + }
109 }
110
111 - memcpy (op->operand, operand, size);
112 op->operand_length = size;
113 op->operand_offset = -1;
114