Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/java.desktop/share/legal/lcms.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Little Color Management System (LCMS) v2.18
## Little Color Management System (LCMS) v2.19.1

### LCMS License
<pre>
Expand Down Expand Up @@ -86,6 +86,7 @@ Amyspark
Lovell Fuller
Eli Schwartz
Diogo Teles Sant'Anna
Vlad Erium
Special Thanks
--------------
Expand Down
42 changes: 33 additions & 9 deletions src/java.desktop/share/native/liblcms/cmscgats.c
Original file line number Diff line number Diff line change
Expand Up @@ -1274,19 +1274,26 @@ void* AllocChunk(cmsIT8* it8, cmsUInt32Number size)

it8 ->Allocator.Used = 0;
new_block = (cmsUInt8Number*)AllocBigBlock(it8, it8->Allocator.BlockSize);
if (new_block == NULL)
return NULL;
if (new_block == NULL) goto Error;

it8->Allocator.Block = new_block;
}

if (it8->Allocator.Block == NULL)
return NULL;
goto Error;

ptr = it8 ->Allocator.Block + it8 ->Allocator.Used;
it8 ->Allocator.Used += size;

return (void*) ptr;

Error:

SynError(it8, "Allocation error");
it8->Allocator.BlockSize = 0;
it8->Allocator.Used = 0;
it8->Allocator.Block = NULL;
return NULL;
}


Expand Down Expand Up @@ -1706,8 +1713,8 @@ cmsBool SetDataFormat(cmsIT8* it8, int n, const char *label)
return FALSE;
}

if (n >= t -> nSamples) {
SynError(it8, "More than NUMBER_OF_FIELDS fields.");
if (n < 0 || n >= t -> nSamples) {
SynError(it8, "Invalid or more than NUMBER_OF_FIELDS fields.");
return FALSE;
}

Expand All @@ -1720,9 +1727,11 @@ cmsBool SetDataFormat(cmsIT8* it8, int n, const char *label)
}


cmsBool CMSEXPORT cmsIT8SetDataFormat(cmsHANDLE h, int n, const char *Sample)
cmsBool CMSEXPORT cmsIT8SetDataFormat(cmsHANDLE h, int n, const char *Sample)
{
cmsIT8* it8 = (cmsIT8*)h;

_cmsAssert(n >= 0);
return SetDataFormat(it8, n, Sample);
}

Expand Down Expand Up @@ -3144,6 +3153,8 @@ cmsBool ParseCube(cmsIT8* cube, cmsStage** Shaper, cmsStage** CLUT, char title[]
InSymbol(cube);
if (!Check(cube, SINUM, "Shaper size expected")) return FALSE;
shaper_size = cube->inum;
if (shaper_size < 2 || shaper_size > 65536)
return SynError(cube, "LUT_1D_SIZE '%d' is out of bounds", shaper_size);
InSymbol(cube);
break;

Expand Down Expand Up @@ -3209,7 +3220,16 @@ cmsBool ParseCube(cmsIT8* cube, cmsStage** Shaper, cmsStage** CLUT, char title[]

if (lut_size > 0) {

int nodes = lut_size * lut_size * lut_size;
int nodes;

/**
* Professional LUT generation tools (e.g., Nobe LutBake) list 65×65×65 as their highest supported size.
*/
if (lut_size < 2 || lut_size > 65)
return SynError(cube, "LUT size '%d' is not allowed", lut_size);

nodes = lut_size * lut_size * lut_size;


cmsFloat32Number* lut_table = (cmsFloat32Number*) _cmsMalloc(cube->ContextID, nodes * 3 * sizeof(cmsFloat32Number));
if (lut_table == NULL) return FALSE;
Expand Down Expand Up @@ -3280,13 +3300,17 @@ cmsHPROFILE CMSEXPORT cmsCreateDeviceLinkFromCubeFileTHR(cmsContext ContextID, c

// Populates the pipeline
if (Shaper != NULL) {
if (!cmsPipelineInsertStage(Pipeline, cmsAT_BEGIN, Shaper))
if (!cmsPipelineInsertStage(Pipeline, cmsAT_BEGIN, Shaper)) {
cmsStageFree(Shaper);
goto Done;
}
}

if (CLUT != NULL) {
if (!cmsPipelineInsertStage(Pipeline, cmsAT_END, CLUT))
if (!cmsPipelineInsertStage(Pipeline, cmsAT_END, CLUT)) {
cmsStageFree(CLUT);
goto Done;
}
}

// Propagate the description. We put no copyright because we know
Expand Down
55 changes: 49 additions & 6 deletions src/java.desktop/share/native/liblcms/cmserr.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,64 @@ int CMSEXPORT cmsstrcasecmp(const char* s1, const char* s2)
return (toupper(*us1) - toupper(*--us2));
}

#ifdef CMS_LARGE_FILE_SUPPORT

long long int CMSEXPORT cmsfilelength(FILE* f)
{
long long int p, n;

#ifdef CMS_IS_WINDOWS_
p = _ftelli64(f);
if (p == -1LL)
return -1LL;

if (_fseeki64(f, 0, SEEK_END) != 0)
return -1LL;

n = _ftelli64(f);

if (_fseeki64(f, p, SEEK_SET) != 0)
return -1LL;
#else
p = (long long int) ftello(f);
if (p < 0)
return -1LL;

if (fseeko(f, 0, SEEK_END) != 0)
return -1LL;

n = (long long int) ftello(f);

if (fseeko(f, (off_t) p, SEEK_SET) != 0)
return -1LL;
#endif

return n;
}

#else

// long int because C99 specifies ftell in such way (7.19.9.2)
long int CMSEXPORT cmsfilelength(FILE* f)
{
long int p , n;
long int p, n;

p = ftell(f); // register current file position
p = ftell(f);
if (p == -1L)
return -1L;

if (fseek(f, 0, SEEK_END) != 0) {
if (fseek(f, 0, SEEK_END) != 0)
return -1L;
}

n = ftell(f);
fseek(f, p, SEEK_SET); // file position restored

if (fseek(f, p, SEEK_SET) != 0)
return -1L;

return n;
}

#endif

// Memory handling ------------------------------------------------------------------
//
Expand All @@ -104,7 +143,11 @@ long int CMSEXPORT cmsfilelength(FILE* f)
// amount of memory that can be reclaimed. This is mostly as a safety feature to prevent
// bogus or evil code to allocate huge blocks that otherwise lcms would never need.

#define MAX_MEMORY_FOR_ALLOC ((cmsUInt32Number)(1024U*1024U*512U))
#ifdef CMS_LARGE_FILE_SUPPORT
# define MAX_MEMORY_FOR_ALLOC ((cmsUInt32Number)(1024U*1024U*2048U))
#else
# define MAX_MEMORY_FOR_ALLOC ((cmsUInt32Number)(1024U*1024U*512U))
#endif

// User may override this behaviour by using a memory plug-in, which basically replaces
// the default memory management functions. In this case, no check is performed and it
Expand Down
Loading