From c073ef2ed59483c8dccec9fcac930c862885ff91 Mon Sep 17 00:00:00 2001 From: Alisen Chung Date: Tue, 14 Mar 2023 04:04:19 +0000 Subject: [PATCH] 8303482: Update LCMS to 2.15 Reviewed-by: serb, prr, dnguyen --- src/java.desktop/share/legal/lcms.md | 13 +++++++------ src/java.desktop/share/native/liblcms/cmsalpha.c | 2 +- src/java.desktop/share/native/liblcms/cmscam02.c | 4 ++-- src/java.desktop/share/native/liblcms/cmscgats.c | 10 ++++++---- src/java.desktop/share/native/liblcms/cmscnvrt.c | 10 +++++----- src/java.desktop/share/native/liblcms/cmserr.c | 2 +- src/java.desktop/share/native/liblcms/cmsgamma.c | 6 +++++- src/java.desktop/share/native/liblcms/cmshalf.c | 2 +- src/java.desktop/share/native/liblcms/cmsintrp.c | 2 +- src/java.desktop/share/native/liblcms/cmsio0.c | 8 ++++---- src/java.desktop/share/native/liblcms/cmsio1.c | 6 +++++- src/java.desktop/share/native/liblcms/cmslut.c | 2 +- src/java.desktop/share/native/liblcms/cmsmd5.c | 2 +- src/java.desktop/share/native/liblcms/cmsmtrx.c | 2 +- src/java.desktop/share/native/liblcms/cmsnamed.c | 12 ++++++++++-- src/java.desktop/share/native/liblcms/cmsopt.c | 6 +++++- src/java.desktop/share/native/liblcms/cmspack.c | 10 +++++----- src/java.desktop/share/native/liblcms/cmspcs.c | 2 +- .../share/native/liblcms/cmsplugin.c | 16 +++++++++------- src/java.desktop/share/native/liblcms/cmsps2.c | 2 +- src/java.desktop/share/native/liblcms/cmssamp.c | 7 +++---- src/java.desktop/share/native/liblcms/cmssm.c | 2 +- src/java.desktop/share/native/liblcms/cmstypes.c | 14 ++++++++++++-- src/java.desktop/share/native/liblcms/cmsvirt.c | 2 +- src/java.desktop/share/native/liblcms/cmswtpnt.c | 7 +++++-- src/java.desktop/share/native/liblcms/cmsxform.c | 2 +- src/java.desktop/share/native/liblcms/lcms2.h | 8 ++++---- .../share/native/liblcms/lcms2_internal.h | 3 +-- .../share/native/liblcms/lcms2_plugin.h | 2 +- 29 files changed, 101 insertions(+), 65 deletions(-) diff --git a/src/java.desktop/share/legal/lcms.md b/src/java.desktop/share/legal/lcms.md index 1576edb8db6..da86a9c47ca 100644 --- a/src/java.desktop/share/legal/lcms.md +++ b/src/java.desktop/share/legal/lcms.md @@ -1,8 +1,7 @@ -## Little Color Management System (LCMS) v2.14 +## Little Color Management System (LCMS) v2.15 ### LCMS License
-
 README.1ST file information
 
 LittleCMS core is released under MIT License
@@ -10,7 +9,7 @@ LittleCMS core is released under MIT License
 ---------------------------------
 
 Little CMS
-Copyright (c) 1998-2022 Marti Maria Saguer
+Copyright (c) 1998-2023 Marti Maria Saguer
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
@@ -32,7 +31,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 ---------------------------------
-
 The below license applies to the following files:
 liblcms/cmssm.c
 
@@ -44,12 +42,12 @@ SoftSurfer makes no warranty for this code, and cannot be held
 liable for any real or imagined damage resulting from its use.
 Users of this code must verify correctness for their application.
 
-
 
### AUTHORS File Information ``` + Main Author ------------ Marti Maria @@ -90,11 +88,15 @@ Mark Allen Noel Carboni Sergei Trofimovic Philipp Knechtges +Amyspark +Lovell Fuller +Eli Schwartz Special Thanks -------------- Artifex software AlienSkin software +libVIPS Jan Morovic Jos Vernon (WebSupergoo) Harald Schneider (Maxon) @@ -103,5 +105,4 @@ Dimitrios Anastassakis Lemke Software Tim Zaman - ``` diff --git a/src/java.desktop/share/native/liblcms/cmsalpha.c b/src/java.desktop/share/native/liblcms/cmsalpha.c index c6a37e79727..e69259e8a51 100644 --- a/src/java.desktop/share/native/liblcms/cmsalpha.c +++ b/src/java.desktop/share/native/liblcms/cmsalpha.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), diff --git a/src/java.desktop/share/native/liblcms/cmscam02.c b/src/java.desktop/share/native/liblcms/cmscam02.c index 23f12419676..71a48d43de4 100644 --- a/src/java.desktop/share/native/liblcms/cmscam02.c +++ b/src/java.desktop/share/native/liblcms/cmscam02.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -353,7 +353,7 @@ CAM02COLOR HPEtoCAT02(CAM02COLOR clr) M[5] = ((-0.7036 * 0.201908) + (1.6975 * 0.000008) + 0.0061); M[6] = (( 0.0030 * 1.910197) + (0.0136 * 0.370950)); M[7] = (( 0.0030 * -1.112124) + (0.0136 * 0.629054)); - M[8] = (( 0.0030 * 0.201908) + (0.0136 * 0.000008) + 0.9834);; + M[8] = (( 0.0030 * 0.201908) + (0.0136 * 0.000008) + 0.9834); clr.RGBc[0] = (clr.RGBp[0] * M[0]) + (clr.RGBp[1] * M[1]) + (clr.RGBp[2] * M[2]); clr.RGBc[1] = (clr.RGBp[0] * M[3]) + (clr.RGBp[1] * M[4]) + (clr.RGBp[2] * M[5]); diff --git a/src/java.desktop/share/native/liblcms/cmscgats.c b/src/java.desktop/share/native/liblcms/cmscgats.c index 61d5533e540..9d0aea27d73 100644 --- a/src/java.desktop/share/native/liblcms/cmscgats.c +++ b/src/java.desktop/share/native/liblcms/cmscgats.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -1968,13 +1968,15 @@ cmsBool CMSEXPORT cmsIT8SaveToMem(cmsHANDLE hIT8, void *MemPtr, cmsUInt32Number* memset(&sd, 0, sizeof(sd)); sd.stream = NULL; - sd.Base = (cmsUInt8Number*) MemPtr; + sd.Base = (cmsUInt8Number*) MemPtr; sd.Ptr = sd.Base; sd.Used = 0; - if (sd.Base) - sd.Max = *BytesNeeded; // Write to memory? + if (sd.Base && (*BytesNeeded > 0)) { + + sd.Max = (*BytesNeeded) - 1; // Write to memory? + } else sd.Max = 0; // Just counting the needed bytes diff --git a/src/java.desktop/share/native/liblcms/cmscnvrt.c b/src/java.desktop/share/native/liblcms/cmscnvrt.c index 535a9e12d7e..b73d594f2ec 100644 --- a/src/java.desktop/share/native/liblcms/cmscnvrt.c +++ b/src/java.desktop/share/native/liblcms/cmscnvrt.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -399,11 +399,11 @@ cmsBool ComputeConversion(cmsUInt32Number i, cmsCIEXYZ WhitePointIn, WhitePointOut; cmsMAT3 ChromaticAdaptationMatrixIn, ChromaticAdaptationMatrixOut; - _cmsReadMediaWhitePoint(&WhitePointIn, hProfiles[i-1]); - _cmsReadCHAD(&ChromaticAdaptationMatrixIn, hProfiles[i-1]); + if (!_cmsReadMediaWhitePoint(&WhitePointIn, hProfiles[i - 1])) return FALSE; + if (!_cmsReadCHAD(&ChromaticAdaptationMatrixIn, hProfiles[i - 1])) return FALSE; - _cmsReadMediaWhitePoint(&WhitePointOut, hProfiles[i]); - _cmsReadCHAD(&ChromaticAdaptationMatrixOut, hProfiles[i]); + if (!_cmsReadMediaWhitePoint(&WhitePointOut, hProfiles[i])) return FALSE; + if (!_cmsReadCHAD(&ChromaticAdaptationMatrixOut, hProfiles[i])) return FALSE; if (!ComputeAbsoluteIntent(AdaptationState, &WhitePointIn, &ChromaticAdaptationMatrixIn, diff --git a/src/java.desktop/share/native/liblcms/cmserr.c b/src/java.desktop/share/native/liblcms/cmserr.c index 772a0a169e5..739cc0b2c98 100644 --- a/src/java.desktop/share/native/liblcms/cmserr.c +++ b/src/java.desktop/share/native/liblcms/cmserr.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), diff --git a/src/java.desktop/share/native/liblcms/cmsgamma.c b/src/java.desktop/share/native/liblcms/cmsgamma.c index b5fd47a8ed1..08409434064 100644 --- a/src/java.desktop/share/native/liblcms/cmsgamma.c +++ b/src/java.desktop/share/native/liblcms/cmsgamma.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -852,6 +852,10 @@ cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurveFloat(cmsContext ContextID, cm { cmsCurveSegment Seg[3]; + // Do some housekeeping + if (nEntries == 0 || values == NULL) + return NULL; + // A segmented tone curve should have function segments in the first and last positions // Initialize segmented curve part up to 0 to constant value = samples[0] Seg[0].x0 = MINUS_INF; diff --git a/src/java.desktop/share/native/liblcms/cmshalf.c b/src/java.desktop/share/native/liblcms/cmshalf.c index eb1d4aa6ea1..5babb063eb0 100644 --- a/src/java.desktop/share/native/liblcms/cmshalf.c +++ b/src/java.desktop/share/native/liblcms/cmshalf.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), diff --git a/src/java.desktop/share/native/liblcms/cmsintrp.c b/src/java.desktop/share/native/liblcms/cmsintrp.c index 7fe74feafd0..9837454df0b 100644 --- a/src/java.desktop/share/native/liblcms/cmsintrp.c +++ b/src/java.desktop/share/native/liblcms/cmsintrp.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), diff --git a/src/java.desktop/share/native/liblcms/cmsio0.c b/src/java.desktop/share/native/liblcms/cmsio0.c index 8d0c014c0fe..6763970f619 100644 --- a/src/java.desktop/share/native/liblcms/cmsio0.c +++ b/src/java.desktop/share/native/liblcms/cmsio0.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -1951,7 +1951,7 @@ cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature si if (data != NULL) { if (BufferSize < TagSize) - goto Error; + TagSize = BufferSize; if (!Icc ->IOhandler ->Seek(Icc ->IOhandler, Offset)) goto Error; if (!Icc ->IOhandler ->Read(Icc ->IOhandler, data, 1, TagSize)) goto Error; @@ -1964,7 +1964,7 @@ cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature si return Icc ->TagSizes[i]; } - // The data has been already read, or written. But wait!, maybe the user chose to save as + // The data has been already read, or written. But wait!, maybe the user choose to save as // raw data. In this case, return the raw data directly if (Icc ->TagSaveAsRaw[i]) { @@ -1973,7 +1973,7 @@ cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature si TagSize = Icc ->TagSizes[i]; if (BufferSize < TagSize) - goto Error; + TagSize = BufferSize; memmove(data, Icc ->TagPtrs[i], TagSize); diff --git a/src/java.desktop/share/native/liblcms/cmsio1.c b/src/java.desktop/share/native/liblcms/cmsio1.c index 85d9f6788b5..bd8a832ac40 100644 --- a/src/java.desktop/share/native/liblcms/cmsio1.c +++ b/src/java.desktop/share/native/liblcms/cmsio1.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -880,6 +880,10 @@ cmsBool CMSEXPORT cmsIsCLUT(cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUI return FALSE; } + // Extended intents are not strictly CLUT-based + if (Intent > INTENT_ABSOLUTE_COLORIMETRIC) + return FALSE; + return cmsIsTag(hProfile, TagTable[Intent]); } diff --git a/src/java.desktop/share/native/liblcms/cmslut.c b/src/java.desktop/share/native/liblcms/cmslut.c index 457ab6ecf5c..24114632ad0 100644 --- a/src/java.desktop/share/native/liblcms/cmslut.c +++ b/src/java.desktop/share/native/liblcms/cmslut.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), diff --git a/src/java.desktop/share/native/liblcms/cmsmd5.c b/src/java.desktop/share/native/liblcms/cmsmd5.c index ea97c0d8774..01aa44de85a 100644 --- a/src/java.desktop/share/native/liblcms/cmsmd5.c +++ b/src/java.desktop/share/native/liblcms/cmsmd5.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), diff --git a/src/java.desktop/share/native/liblcms/cmsmtrx.c b/src/java.desktop/share/native/liblcms/cmsmtrx.c index 9bbe82871f5..599c290bd70 100644 --- a/src/java.desktop/share/native/liblcms/cmsmtrx.c +++ b/src/java.desktop/share/native/liblcms/cmsmtrx.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), diff --git a/src/java.desktop/share/native/liblcms/cmsnamed.c b/src/java.desktop/share/native/liblcms/cmsnamed.c index c710ba39372..04280180230 100644 --- a/src/java.desktop/share/native/liblcms/cmsnamed.c +++ b/src/java.desktop/share/native/liblcms/cmsnamed.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -399,6 +399,8 @@ const wchar_t* _cmsMLUgetWide(const cmsMLU* mlu, if (len != NULL) *len = v ->Len; + if (v->StrW + v->Len > mlu->PoolSize) return NULL; + return(wchar_t*) ((cmsUInt8Number*) mlu ->MemPool + v ->StrW); } @@ -790,7 +792,13 @@ cmsStage* CMSEXPORT _cmsStageAllocNamedColor(cmsNAMEDCOLORLIST* NamedColorList, cmsNAMEDCOLORLIST* CMSEXPORT cmsGetNamedColorList(cmsHTRANSFORM xform) { _cmsTRANSFORM* v = (_cmsTRANSFORM*) xform; - cmsStage* mpe = v ->Lut->Elements; + cmsStage* mpe; + + if (v == NULL) return NULL; + if (v->Lut == NULL) return NULL; + + mpe = v->Lut->Elements; + if (mpe == NULL) return NULL; if (mpe ->Type != cmsSigNamedColorElemType) return NULL; return (cmsNAMEDCOLORLIST*) mpe ->Data; diff --git a/src/java.desktop/share/native/liblcms/cmsopt.c b/src/java.desktop/share/native/liblcms/cmsopt.c index e32f73b86ee..3e81ae1df1b 100644 --- a/src/java.desktop/share/native/liblcms/cmsopt.c +++ b/src/java.desktop/share/native/liblcms/cmsopt.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -1724,6 +1724,10 @@ cmsBool OptimizeMatrixShaper(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3 _cmsStageMatrixData* Data1 = (_cmsStageMatrixData*)cmsStageData(Matrix1); _cmsStageMatrixData* Data2 = (_cmsStageMatrixData*)cmsStageData(Matrix2); + // Only RGB to RGB + if (Matrix1->InputChannels != 3 || Matrix1->OutputChannels != 3 || + Matrix2->InputChannels != 3 || Matrix2->OutputChannels != 3) return FALSE; + // Input offset should be zero if (Data1->Offset != NULL) return FALSE; diff --git a/src/java.desktop/share/native/liblcms/cmspack.c b/src/java.desktop/share/native/liblcms/cmspack.c index e90e45656fc..da5fc6019d3 100644 --- a/src/java.desktop/share/native/liblcms/cmspack.c +++ b/src/java.desktop/share/native/liblcms/cmspack.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -1736,7 +1736,7 @@ cmsUInt8Number* PackChunkyBytes(CMSREGISTER _cmsTRANSFORM* info, if (Reverse) v = REVERSE_FLAVOR_16(v); - if (Premul && alpha_factor != 0) + if (Premul) { v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16); } @@ -1805,7 +1805,7 @@ cmsUInt8Number* PackChunkyWords(CMSREGISTER _cmsTRANSFORM* info, if (Reverse) v = REVERSE_FLAVOR_16(v); - if (Premul && alpha_factor != 0) + if (Premul) { v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16); } @@ -1872,7 +1872,7 @@ cmsUInt8Number* PackPlanarBytes(CMSREGISTER _cmsTRANSFORM* info, if (Reverse) v = REVERSE_FLAVOR_16(v); - if (Premul && alpha_factor != 0) + if (Premul) { v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16); } @@ -1932,7 +1932,7 @@ cmsUInt8Number* PackPlanarWords(CMSREGISTER _cmsTRANSFORM* info, if (Reverse) v = REVERSE_FLAVOR_16(v); - if (Premul && alpha_factor != 0) + if (Premul) { v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16); } diff --git a/src/java.desktop/share/native/liblcms/cmspcs.c b/src/java.desktop/share/native/liblcms/cmspcs.c index f17c74b4b2d..c4739840053 100644 --- a/src/java.desktop/share/native/liblcms/cmspcs.c +++ b/src/java.desktop/share/native/liblcms/cmspcs.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), diff --git a/src/java.desktop/share/native/liblcms/cmsplugin.c b/src/java.desktop/share/native/liblcms/cmsplugin.c index 87c74390bdb..c2808bb9278 100644 --- a/src/java.desktop/share/native/liblcms/cmsplugin.c +++ b/src/java.desktop/share/native/liblcms/cmsplugin.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -825,8 +825,6 @@ void* _cmsContextGetClientChunk(cmsContext ContextID, _cmsMemoryClient mc) // identify which plug-in to unregister. void CMSEXPORT cmsUnregisterPluginsTHR(cmsContext ContextID) { - struct _cmsContext_struct* ctx = _cmsGetContext(ContextID); - _cmsRegisterMemHandlerPlugin(ContextID, NULL); _cmsRegisterInterpPlugin(ContextID, NULL); _cmsRegisterTagTypePlugin(ContextID, NULL); @@ -840,9 +838,6 @@ void CMSEXPORT cmsUnregisterPluginsTHR(cmsContext ContextID) _cmsRegisterMutexPlugin(ContextID, NULL); _cmsRegisterParallelizationPlugin(ContextID, NULL); - if (ctx->MemPool != NULL) - _cmsSubAllocDestroy(ctx->MemPool); - ctx->MemPool = NULL; } @@ -1010,7 +1005,14 @@ cmsContext CMSEXPORT cmsDupContext(cmsContext ContextID, void* NewUserData) // The ContextID can no longer be used in any THR operation. void CMSEXPORT cmsDeleteContext(cmsContext ContextID) { - if (ContextID != NULL) { + if (ContextID == NULL) { + + cmsUnregisterPlugins(); + if (globalContext.MemPool != NULL) + _cmsSubAllocDestroy(globalContext.MemPool); + globalContext.MemPool = NULL; + } + else { struct _cmsContext_struct* ctx = (struct _cmsContext_struct*) ContextID; struct _cmsContext_struct fakeContext; diff --git a/src/java.desktop/share/native/liblcms/cmsps2.c b/src/java.desktop/share/native/liblcms/cmsps2.c index c0816347d24..537f6854067 100644 --- a/src/java.desktop/share/native/liblcms/cmsps2.c +++ b/src/java.desktop/share/native/liblcms/cmsps2.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), diff --git a/src/java.desktop/share/native/liblcms/cmssamp.c b/src/java.desktop/share/native/liblcms/cmssamp.c index cf4a13968d1..8a01f7ec685 100644 --- a/src/java.desktop/share/native/liblcms/cmssamp.c +++ b/src/java.desktop/share/native/liblcms/cmssamp.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -152,10 +152,9 @@ cmsBool BlackPointAsDarkerColorant(cmsHPROFILE hInput, // Convert black to Lab cmsDoTransform(xform, Black, &Lab, 1); - // Force it to be neutral, clip to max. L* of 50 + // Force it to be neutral, check for inconsistences Lab.a = Lab.b = 0; - if (Lab.L > 50) Lab.L = 50; - if (Lab.L < 0) Lab.L = 0; + if (Lab.L > 50 || Lab.L < 0) Lab.L = 0; // Free the resources cmsDeleteTransform(xform); diff --git a/src/java.desktop/share/native/liblcms/cmssm.c b/src/java.desktop/share/native/liblcms/cmssm.c index 4300d164df6..3e1486ae3ae 100644 --- a/src/java.desktop/share/native/liblcms/cmssm.c +++ b/src/java.desktop/share/native/liblcms/cmssm.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), diff --git a/src/java.desktop/share/native/liblcms/cmstypes.c b/src/java.desktop/share/native/liblcms/cmstypes.c index 898b5e8ffd6..7b07b6b9cf4 100644 --- a/src/java.desktop/share/native/liblcms/cmstypes.c +++ b/src/java.desktop/share/native/liblcms/cmstypes.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -1549,6 +1549,12 @@ void *Type_MLU_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsU if (!_cmsReadUInt32Number(io, &Len)) goto Error; if (!_cmsReadUInt32Number(io, &Offset)) goto Error; + // Offset MUST be even because it indexes a block of utf16 chars. + // Tricky profiles that uses odd positions will not work anyway + // because the whole utf16 block is previously converted to wchar_t + // and sizeof this type may be of 4 bytes. On Linux systems, for example. + if (Offset & 1) goto Error; + // Check for overflow if (Offset < (SizeOfHeader + 8)) goto Error; if (((Offset + Len) < Len) || ((Offset + Len) > SizeOfTag + 8)) goto Error; @@ -1576,8 +1582,12 @@ void *Type_MLU_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsU } else { - Block = (wchar_t*) _cmsMalloc(self ->ContextID, SizeOfTag); + // Make sure this is an even utf16 size. + if (SizeOfTag & 1) goto Error; + + Block = (wchar_t*) _cmsCalloc(self ->ContextID, 1, SizeOfTag); if (Block == NULL) goto Error; + NumOfWchar = SizeOfTag / sizeof(wchar_t); if (!_cmsReadWCharArray(io, NumOfWchar, Block)) { _cmsFree(self->ContextID, Block); diff --git a/src/java.desktop/share/native/liblcms/cmsvirt.c b/src/java.desktop/share/native/liblcms/cmsvirt.c index 6d15f1fde13..6ce04796174 100644 --- a/src/java.desktop/share/native/liblcms/cmsvirt.c +++ b/src/java.desktop/share/native/liblcms/cmsvirt.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), diff --git a/src/java.desktop/share/native/liblcms/cmswtpnt.c b/src/java.desktop/share/native/liblcms/cmswtpnt.c index 96bad5de7ca..27d71803531 100644 --- a/src/java.desktop/share/native/liblcms/cmswtpnt.c +++ b/src/java.desktop/share/native/liblcms/cmswtpnt.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -244,12 +244,15 @@ cmsBool ComputeChromaticAdaptation(cmsMAT3* Conversion, _cmsMAT3eval(&ConeSourceRGB, Chad, &ConeSourceXYZ); _cmsMAT3eval(&ConeDestRGB, Chad, &ConeDestXYZ); + if ((fabs(ConeSourceRGB.n[0]) < MATRIX_DET_TOLERANCE) || + (fabs(ConeSourceRGB.n[1]) < MATRIX_DET_TOLERANCE) || + (fabs(ConeSourceRGB.n[2]) < MATRIX_DET_TOLERANCE)) return FALSE; + // Build matrix _cmsVEC3init(&Cone.v[0], ConeDestRGB.n[0]/ConeSourceRGB.n[0], 0.0, 0.0); _cmsVEC3init(&Cone.v[1], 0.0, ConeDestRGB.n[1]/ConeSourceRGB.n[1], 0.0); _cmsVEC3init(&Cone.v[2], 0.0, 0.0, ConeDestRGB.n[2]/ConeSourceRGB.n[2]); - // Normalize _cmsMAT3per(&Tmp, &Cone, Chad); _cmsMAT3per(Conversion, &Chad_Inv, &Tmp); diff --git a/src/java.desktop/share/native/liblcms/cmsxform.c b/src/java.desktop/share/native/liblcms/cmsxform.c index 8b8f831f0af..3f3ad28c6c4 100644 --- a/src/java.desktop/share/native/liblcms/cmsxform.c +++ b/src/java.desktop/share/native/liblcms/cmsxform.c @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), diff --git a/src/java.desktop/share/native/liblcms/lcms2.h b/src/java.desktop/share/native/liblcms/lcms2.h index ab122f3b342..d5b8c477f23 100644 --- a/src/java.desktop/share/native/liblcms/lcms2.h +++ b/src/java.desktop/share/native/liblcms/lcms2.h @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -52,7 +52,7 @@ // //--------------------------------------------------------------------------------- // -// Version 2.14 +// Version 2.15 // #ifndef _lcms2_H @@ -110,7 +110,7 @@ extern "C" { #endif // Version/release -#define LCMS_VERSION 2140 +#define LCMS_VERSION 2150 // I will give the chance of redefining basic types for compilers that are not fully C99 compliant #ifndef CMS_BASIC_TYPES_ALREADY_DEFINED @@ -256,7 +256,7 @@ typedef int cmsBool; // Calling convention -- this is hardly platform and compiler dependent -#ifdef CMS_IS_WINDOWS_ +#if defined(CMS_IS_WINDOWS_) && !defined(__GNUC__) # if defined(CMS_DLL) || defined(CMS_DLL_BUILD) # ifdef __BORLANDC__ # define CMSEXPORT __stdcall _export diff --git a/src/java.desktop/share/native/liblcms/lcms2_internal.h b/src/java.desktop/share/native/liblcms/lcms2_internal.h index 3999e24d771..4c29a6c0218 100644 --- a/src/java.desktop/share/native/liblcms/lcms2_internal.h +++ b/src/java.desktop/share/native/liblcms/lcms2_internal.h @@ -27,10 +27,9 @@ // However, the following notice accompanied the original version of this // file: // - // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), diff --git a/src/java.desktop/share/native/liblcms/lcms2_plugin.h b/src/java.desktop/share/native/liblcms/lcms2_plugin.h index 1dc1a4661e2..e7e7bd1f0ce 100644 --- a/src/java.desktop/share/native/liblcms/lcms2_plugin.h +++ b/src/java.desktop/share/native/liblcms/lcms2_plugin.h @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2022 Marti Maria Saguer +// Copyright (c) 1998-2023 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"),