blob: 8232e21cc7e7cf2afc6a46610903a5e046a15d28 [file] [log] [blame]
Lei Zhang72aa5fb2023-05-30 22:53:57 +00001diff --git a/third_party/lcms/src/cmsopt.c b/third_party/lcms/src/cmsopt.c
2index e3212fb4d..a5475709b 100644
3--- a/third_party/lcms/src/cmsopt.c
4+++ b/third_party/lcms/src/cmsopt.c
5@@ -100,6 +100,15 @@ typedef struct {
6
7 } Curves16Data;
8
9+// A simple adapter to prevent _cmsPipelineEval16Fn vs. _cmsInterpFn16
10+// confusion, which trips up UBSAN.
11+static
12+void Lerp16Adapter(CMSREGISTER const cmsUInt16Number in[],
13+ CMSREGISTER cmsUInt16Number out[],
14+ const void* data) {
15+ cmsInterpParams* params = (cmsInterpParams*)data;
16+ params->Interpolation.Lerp16(in, out, params);
17+}
18
19 // Simple optimizations ----------------------------------------------------------------------------------------------------------
20
21@@ -805,7 +814,7 @@ Error:
22
23 if (DataSetIn == NULL && DataSetOut == NULL) {
24
25- _cmsPipelineSetOptimizationParameters(Dest, (_cmsPipelineEval16Fn) DataCLUT->Params->Interpolation.Lerp16, DataCLUT->Params, NULL, NULL);
26+ _cmsPipelineSetOptimizationParameters(Dest, Lerp16Adapter, DataCLUT->Params, NULL, NULL);
27 }
28 else {
29