summaryrefslogtreecommitdiff
path: root/external/lcms2/ubsan.patch.0
blob: 0b64484c6eabcd33b1587f82bc540c4ee384d23c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--- src/cmsnamed.c
+++ src/cmsnamed.c
@@ -221,7 +221,7 @@
 cmsBool  CMSEXPORT cmsMLUsetWide(cmsMLU* mlu, const char Language[3], const char Country[3], const wchar_t* WideString)
 {
     cmsUInt16Number Lang  = _cmsAdjustEndianess16(*(cmsUInt16Number*) Language);
-    cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) Country);
+    cmsUInt16Number Cntry = Country[0] | ((cmsUInt16Number) Country[1]) << 8;
     cmsUInt32Number len;
 
     if (mlu == NULL) return FALSE;
--- src/lcms2_internal.h
+++ src/lcms2_internal.h
@@ -93,7 +93,7 @@
 
 // A fast way to convert from/to 16 <-> 8 bits
 #define FROM_8_TO_16(rgb) (cmsUInt16Number) ((((cmsUInt16Number) (rgb)) << 8)|(rgb))
-#define FROM_16_TO_8(rgb) (cmsUInt8Number) ((((rgb) * 65281 + 8388608) >> 24) & 0xFF)
+#define FROM_16_TO_8(rgb) (cmsUInt8Number) ((((unsigned)(rgb) * 65281 + 8388608) >> 24) & 0xFF)
 
 // Code analysis is broken on asserts
 #ifdef _MSC_VER