Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / external / cairo / pixman / pixman-ubsan.patch
blob64e5778ee4d4ffd2a0de96ed7f32b6acc9245485
1 diff -ru pixman-0.42.2.orig/pixman/pixman-bits-image.c pixman-0.42.2/pixman/pixman-bits-image.c
2 --- misc/pixman-0.42.2.orig/pixman/pixman-bits-image.c 2022-11-03 02:25:48.000000000 +0900
3 +++ misc/build/pixman-0.42.2/pixman/pixman-bits-image.c 2022-11-28 21:35:25.896969126 +0900
4 @@ -351,8 +351,8 @@
5 * positioned relative to a particular phase (and not relative to whatever
6 * exact fraction we happen to get here).
7 */
8 - x = ((x >> x_phase_shift) << x_phase_shift) + ((1 << x_phase_shift) >> 1);
9 - y = ((y >> y_phase_shift) << y_phase_shift) + ((1 << y_phase_shift) >> 1);
10 + x = ((uint32_t)(x >> x_phase_shift) << x_phase_shift) + ((1 << x_phase_shift) >> 1);
11 + y = ((uint32_t)(y >> y_phase_shift) << y_phase_shift) + ((1 << y_phase_shift) >> 1);
13 px = (x & 0xffff) >> x_phase_shift;
14 py = (y & 0xffff) >> y_phase_shift;
15 diff -ru pixman-0.42.2.orig/pixman/pixman-combine32.c pixman-0.42.2/pixman/pixman-combine32.c
16 --- misc/pixman-0.42.2.orig/pixman/pixman-combine32.c 2022-02-02 05:51:25.000000000 +0900
17 +++ misc/build/pixman-0.42.2/pixman/pixman-combine32.c 2022-11-28 21:38:48.226968594 +0900
18 @@ -589,7 +589,7 @@
19 rg = DIV_ONE_UN8 (rg); \
20 rb = DIV_ONE_UN8 (rb); \
22 - *(dest + i) = ra << 24 | rr << 16 | rg << 8 | rb; \
23 + *(dest + i) = (uint32_t)ra << 24 | rr << 16 | rg << 8 | rb; \
24 } \
25 } \
27 diff -ru pixman-0.42.2.orig/pixman/pixman-fast-path.c pixman-0.42.2/pixman/pixman-fast-path.c
28 --- misc/pixman-0.42.2.orig/pixman/pixman-fast-path.c 2022-10-18 02:47:42.000000000 +0900
29 +++ misc/build/pixman-0.42.2/pixman/pixman-fast-path.c 2022-11-28 21:53:12.596963317 +0900
30 @@ -2758,8 +2758,8 @@
31 * positioned relative to a particular phase (and not relative to whatever
32 * exact fraction we happen to get here).
34 - x = ((vx >> x_phase_shift) << x_phase_shift) + ((1 << x_phase_shift) >> 1);
35 - y = ((vy >> y_phase_shift) << y_phase_shift) + ((1 << y_phase_shift) >> 1);
36 + x = ((uint32_t)(vx >> x_phase_shift) << x_phase_shift) + ((1 << x_phase_shift) >> 1);
37 + y = ((uint32_t)(vy >> y_phase_shift) << y_phase_shift) + ((1 << y_phase_shift) >> 1);
39 px = (x & 0xffff) >> x_phase_shift;
40 py = (y & 0xffff) >> y_phase_shift;
41 @@ -2837,9 +2837,9 @@
42 sbtot = CLIP (sbtot, 0, 0xff);
44 #ifdef WORDS_BIGENDIAN
45 - buffer[k] = (satot << 0) | (srtot << 8) | (sgtot << 16) | (sbtot << 24);
46 + buffer[k] = (satot << 0) | (srtot << 8) | (sgtot << 16) | ((uint32_t)sbtot << 24);
47 #else
48 - buffer[k] = (satot << 24) | (srtot << 16) | (sgtot << 8) | (sbtot << 0);
49 + buffer[k] = ((uint32_t)satot << 24) | (srtot << 16) | (sgtot << 8) | (sbtot << 0);
50 #endif
52 next:
53 diff -ru pixman-0.42.2.orig/pixman/pixman-sse2.c pixman-0.42.2/pixman/pixman-sse2.c
54 --- misc/pixman-0.42.2/pixman/pixman-sse2.c 2022-02-02 05:51:25.000000000 +0900
55 +++ misc/build/pixman-0.42.2/pixman/pixman-sse2.c 2022-11-28 22:11:19.276969466 +0900
56 @@ -3345,7 +3345,7 @@
58 b = filler & 0xff;
59 w = (b << 8) | b;
60 - filler = (w << 16) | w;
61 + filler = ((uint32_t)w << 16) | w;
63 else if (bpp == 16)
65 diff -ru pixman-0.42.2.orig/pixman/pixman-utils.c pixman-0.42.2/pixman/pixman-utils.c
66 --- misc/pixman-0.42.2.orig/pixman/pixman-utils.c 2022-02-02 05:51:25.000000000 +0900
67 +++ misc/build/pixman-0.42.2/pixman/pixman-utils.c 2022-11-28 21:55:44.196964912 +0900
68 @@ -213,7 +213,7 @@
69 g = float_to_unorm (src[i].g, 8);
70 b = float_to_unorm (src[i].b, 8);
72 - dst[i] = (a << 24) | (r << 16) | (g << 8) | (b << 0);
73 + dst[i] = ((uint32_t)a << 24) | (r << 16) | (g << 8) | (b << 0);