summaryrefslogtreecommitdiff
path: root/external/cairo/cairo/san.patch.0
blob: 9e187240f2408ef0a4f4330f18498811291fd81a (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
--- src/cairo-fixed-private.h
+++ src/cairo-fixed-private.h
@@ -61,7 +61,7 @@
 static inline cairo_fixed_t
 _cairo_fixed_from_int (int i)
 {
-    return i << CAIRO_FIXED_FRAC_BITS;
+    return (unsigned)i << CAIRO_FIXED_FRAC_BITS;
 }
 
 /* This is the "magic number" approach to converting a double into fixed
@@ -249,7 +249,7 @@
     } else if ((f >> CAIRO_FIXED_FRAC_BITS) > INT16_MAX) {
 	x = INT32_MAX;
     } else {
-	x = f << (16 - CAIRO_FIXED_FRAC_BITS);
+	x = (uint32_t)f << (16 - CAIRO_FIXED_FRAC_BITS);
     }
 
     return x;
--- src/cairo-gstate.c
+++ src/cairo-gstate.c
@@ -2297,7 +2297,7 @@
 		if (!drop || KEEP_GLYPH (transformed_glyphs[j]))
 		    j++;
 	    }
-	    memcpy (transformed_clusters, clusters,
+	    if (num_clusters != 0) memcpy (transformed_clusters, clusters,
 		    num_clusters * sizeof (cairo_text_cluster_t));
 	} else {
 	    const cairo_glyph_t *cur_glyph;
@@ -2352,7 +2352,7 @@
 		if (! drop || KEEP_GLYPH (transformed_glyphs[j]))
 		    j++;
 	    }
-	    memcpy (transformed_clusters, clusters,
+	    if (num_clusters != 0) memcpy (transformed_clusters, clusters,
 		    num_clusters * sizeof (cairo_text_cluster_t));
 	} else {
 	    const cairo_glyph_t *cur_glyph;
--- src/cairo-image-compositor.c
+++ src/cairo-image-compositor.c
@@ -130,10 +130,10 @@
 color_to_uint32 (const cairo_color_t *color)
 {
     return
-        (color->alpha_short >> 8 << 24) |
-        (color->red_short >> 8 << 16)   |
-        (color->green_short & 0xff00)   |
-        (color->blue_short >> 8);
+        ((uint32_t)color->alpha_short >> 8 << 24) |
+        ((uint32_t)color->red_short >> 8 << 16)   |
+        ((uint32_t)color->green_short & 0xff00)   |
+        ((uint32_t)color->blue_short >> 8);
 }
 
 static inline cairo_bool_t
--- src/cairo-image-source.c
+++ src/cairo-image-source.c
@@ -509,7 +509,11 @@
 	return pixman_image_create_solid_fill (&color);
 
     case CAIRO_FORMAT_RGB24_888:
-	pixel = *(uint32_t *) (image->data + y * image->stride + 3 * x);
+#ifdef WORDS_BIGENDIAN
+	pixel = (uint32_t)(image->data + y * image->stride + 3 * x)[3] | ((uint32_t)(image->data + y * image->stride + 3 * x)[2] << 8) | ((uint32_t)(image->data + y * image->stride + 3 * x)[1] << 16) | ((uint32_t)(image->data + y * image->stride + 3 * x)[0] << 24);
+#else
+	pixel = (uint32_t)(image->data + y * image->stride + 3 * x)[0] | ((uint32_t)(image->data + y * image->stride + 3 * x)[1] << 8) | ((uint32_t)(image->data + y * image->stride + 3 * x)[2] << 16) | ((uint32_t)(image->data + y * image->stride + 3 * x)[3] << 24);
+#endif
 	pixel &= 0x00ffffff; /* ignore next pixel bits */
 	if (pixel == 0)
 	    return _pixman_black_image ();
--- src/cairo-spans-compositor.c
+++ src/cairo-spans-compositor.c
@@ -1041,14 +1041,14 @@
     if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
 	cairo_polygon_t polygon;
 	cairo_fill_rule_t fill_rule = CAIRO_FILL_RULE_WINDING;
+	cairo_box_t limits;
 
 	if (! _cairo_rectangle_contains_rectangle (&extents->unbounded,
 						   &extents->mask))
 	{
 	    if (extents->clip->num_boxes == 1) {
 		_cairo_polygon_init (&polygon, extents->clip->boxes, 1);
 	    } else {
-		cairo_box_t limits;
 		_cairo_box_from_rectangle (&limits, &extents->unbounded);
 		_cairo_polygon_init (&polygon, &limits, 1);
 	    }
@@ -1128,17 +1128,17 @@
     }
     if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
 	cairo_polygon_t polygon;
+	cairo_box_t limits;
 
 	TRACE((stderr, "%s - polygon\n", __FUNCTION__));
 
 	if (! _cairo_rectangle_contains_rectangle (&extents->unbounded,
 						   &extents->mask))
 	{
 	    TRACE((stderr, "%s - clipping to bounds\n", __FUNCTION__));
 	    if (extents->clip->num_boxes == 1) {
 		_cairo_polygon_init (&polygon, extents->clip->boxes, 1);
 	    } else {
-		cairo_box_t limits;
 		_cairo_box_from_rectangle (&limits, &extents->unbounded);
 		_cairo_polygon_init (&polygon, &limits, 1);
 	    }
--- src/cairo-tor-scan-converter.c
+++ src/cairo-tor-scan-converter.c
@@ -253,7 +253,7 @@
 #elif GRID_XY == 15
 #  define  GRID_AREA_TO_ALPHA(c)  (((c) << 4) + (c))
 #elif GRID_XY == 2*256*15
-#  define  GRID_AREA_TO_ALPHA(c)  (((c) + ((c)<<4) + 256) >> 9)
+#  define  GRID_AREA_TO_ALPHA(c)  (((c) + ((uint32_t)(c)<<4) + 256) >> 9)
 #else
 #  define  GRID_AREA_TO_ALPHA(c)  (((c)*255 + GRID_XY/2) / GRID_XY)
 #endif
--- src/cairo-xlib-render-compositor.c
+++ src/cairo-xlib-render-compositor.c
@@ -1849,8 +1849,8 @@
 	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
-    dx = -dst_x << 16;
-    dy = -dst_y << 16;
+    dx = (unsigned)-dst_x << 16;
+    dy = (unsigned)-dst_y << 16;
     for (i = 0; i < traps->num_traps; i++) {
 	cairo_trapezoid_t *t = &traps->traps[i];
 
--- src/cairo-xlib-source.c
+++ src/cairo-xlib-source.c
@@ -567,7 +567,7 @@
 {
     cairo_xlib_display_t *display = dst->display;
     uint32_t pixel =
-	color->alpha_short >> 8 << 24 |
+	(uint32_t)(color->alpha_short >> 8) << 24 |
 	color->red_short   >> 8 << 16 |
 	color->green_short >> 8 << 8 |
 	color->blue_short  >> 8 << 0;
--- src/cairo-xlib-surface-shm.c
+++ src/cairo-xlib-surface-shm.c
@@ -1152,9 +1152,11 @@
     cairo_surface_t *surface;
 
     surface = NULL;
-    if (has_shm (other))
-	surface = &_cairo_xlib_shm_surface_create (other, format, width, height,
-						   FALSE, has_shm_pixmaps (other))->image.base;
+    if (has_shm (other)) {
+	cairo_xlib_shm_surface_t * shm_surface = _cairo_xlib_shm_surface_create (other, format, width, height,
+						   FALSE, has_shm_pixmaps (other));
+	if (shm_surface) surface = &shm_surface->image.base;
+    }
 
     return surface;
 }