SPDX-License-Identifier: MIT
+
+```
diff --git a/src/java.desktop/share/legal/libpng.md b/src/java.desktop/share/legal/libpng.md
index f420ccd94ed..cbffed81332 100644
--- a/src/java.desktop/share/legal/libpng.md
+++ b/src/java.desktop/share/legal/libpng.md
@@ -1,4 +1,4 @@
-## libpng v1.6.40
+## libpng v1.6.43
### libpng License
@@ -9,11 +9,11 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
PNG Reference Library License version 2
---------------------------------------
-Copyright (c) 1995-2023 The PNG Reference Library Authors.
-Copyright (c) 2018-2023 Cosmin Truta
-Copyright (c) 1998-2018 Glenn Randers-Pehrson
-Copyright (c) 1996-1997 Andreas Dilger
-Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
+Copyright (C) 1995-2024 The PNG Reference Library Authors.
+Copyright (C) 2018-2024 Cosmin Truta
+Copyright (C) 1998-2018 Glenn Randers-Pehrson
+Copyright (C) 1996-1997 Andreas Dilger
+Copyright (C) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
The software is supplied "as is", without warranty of any kind,
express or implied, including, without limitation, the warranties
@@ -157,7 +157,9 @@ PNG REFERENCE LIBRARY AUTHORS
This is the list of PNG Reference Library ("libpng") Contributing
Authors, for copyright and licensing purposes.
+ * Adam Richter
* Andreas Dilger
+ * Chris Blume
* Cosmin Truta
* Dave Martindale
* Eric S. Raymond
@@ -186,21 +188,28 @@ Authors, for copyright and licensing purposes.
* Vadim Barkov
* Willem van Schaik
* Zhijie Liang
+ * Apple Inc.
+ - Zixu Wang (王子旭)
* Arm Holdings
- - Richard Townsend
+ - Richard Townsend
* Google Inc.
- - Dan Field
- - Leon Scroggins III
- - Matt Sarett
- - Mike Klein
- - Sami Boukortt
- - Wan-Teh Chang
+ - Dan Field
+ - Leon Scroggins III
+ - Matt Sarett
+ - Mike Klein
+ - Sami Boukortt
+ - Wan-Teh Chang
+ * Loongson Technology Corporation Ltd.
+ - GuXiWei (顾希伟)
+ - JinBo (金波)
+ - ZhangLixia (张利霞)
The build projects, the build scripts, the test scripts, and other
-files in the "ci", "projects", "scripts" and "tests" directories, have
+files in the "projects", "scripts" and "tests" directories, have
other copyright owners, but are released under the libpng license.
-Some files in the "contrib" directory, and some tools-generated files
-that are distributed with libpng, have other copyright owners, and are
-released under other open source licenses.
+Some files in the "ci" and "contrib" directories, as well as some
+of the tools-generated files that are distributed with libpng, have
+other copyright owners, and are released under other open source
+licenses.
```
diff --git a/src/java.desktop/share/native/libfontmanager/freetypeScaler.c b/src/java.desktop/share/native/libfontmanager/freetypeScaler.c
index 21ac280f0fb..f9ebacad66b 100644
--- a/src/java.desktop/share/native/libfontmanager/freetypeScaler.c
+++ b/src/java.desktop/share/native/libfontmanager/freetypeScaler.c
@@ -504,6 +504,8 @@ static double euclidianDistance(double a, double b) {
return sqrt(a*a+b*b);
}
+#define TOO_LARGE(a, b) (abs((int)(a / b)) > 32766)
+
JNIEXPORT jlong JNICALL
Java_sun_font_FreetypeFontScaler_createScalerContextNative(
JNIEnv *env, jobject scaler, jlong pScaler, jdoubleArray matrix,
@@ -515,6 +517,7 @@ Java_sun_font_FreetypeFontScaler_createScalerContextNative(
(FTScalerInfo*) jlong_to_ptr(pScaler);
if (context == NULL) {
+ free(context);
invalidateJavaScaler(env, scaler, NULL);
return (jlong) 0;
}
@@ -524,7 +527,18 @@ Java_sun_font_FreetypeFontScaler_createScalerContextNative(
//text can not be smaller than 1 point
ptsz = 1.0;
}
+ if (ptsz > 16384) {
+ ptsz = 16384; // far enough from 32767
+ fm = TEXT_FM_ON; // avoids calculations which might overflow
+ }
context->ptsz = (int)(ptsz * 64);
+ if (TOO_LARGE(dmat[0], ptsz) || TOO_LARGE(dmat[1], ptsz) ||
+ TOO_LARGE(dmat[2], ptsz) || TOO_LARGE(dmat[3], ptsz))
+ {
+ free(context);
+ return (jlong)0;
+ }
+
context->transform.xx = FloatToFTFixed((float)(dmat[0]/ptsz));
context->transform.yx = -FloatToFTFixed((float)(dmat[1]/ptsz));
context->transform.xy = -FloatToFTFixed((float)(dmat[2]/ptsz));
diff --git a/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c b/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c
index a643b9c111c..a6f4cfdd36e 100644
--- a/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c
+++ b/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -289,13 +289,15 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param,
mlib_d64 dX1 = coords[(topIdx - i) & 0x3][0];
mlib_d64 dY2 = coords[(topIdx - i - 1) & 0x3][1];
mlib_d64 dX2 = coords[(topIdx - i - 1) & 0x3][0];
- mlib_d64 x = dX1, slope = (dX2 - dX1) / (dY2 - dY1);
+ mlib_d64 x = dX1, slope;
mlib_s32 y1;
mlib_s32 y2;
if (dY1 == dY2)
continue;
+ slope = (dX2 - dX1) / (dY2 - dY1);
+
if (!(IS_FINITE(slope))) {
continue;
}
@@ -330,13 +332,15 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param,
mlib_d64 dX1 = coords[(topIdx + i) & 0x3][0];
mlib_d64 dY2 = coords[(topIdx + i + 1) & 0x3][1];
mlib_d64 dX2 = coords[(topIdx + i + 1) & 0x3][0];
- mlib_d64 x = dX1, slope = (dX2 - dX1) / (dY2 - dY1);
+ mlib_d64 x = dX1, slope;
mlib_s32 y1;
mlib_s32 y2;
if (dY1 == dY2)
continue;
+ slope = (dX2 - dX1) / (dY2 - dY1);
+
if (!(IS_FINITE(slope))) {
continue;
}
diff --git a/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c b/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c
index 6ddfb46060d..0b2860b4b50 100644
--- a/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c
+++ b/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c
@@ -34,11 +34,11 @@ SPDX-License-Identifier: MIT
*****************************************************************************/
-#include
+#include
#include
#include
-#include
#include
+#include
#include
#ifdef _WIN32
@@ -55,18 +55,19 @@ SPDX-License-Identifier: MIT
/* avoid extra function call in case we use fread (TVT) */
static int InternalRead(GifFileType *gif, GifByteType *buf, int len) {
- //fprintf(stderr, "### Read: %d\n", len);
- return
- (((GifFilePrivateType*)gif->Private)->Read ?
- ((GifFilePrivateType*)gif->Private)->Read(gif,buf,len) :
- fread(buf,1,len,((GifFilePrivateType*)gif->Private)->File));
+ // fprintf(stderr, "### Read: %d\n", len);
+ return (((GifFilePrivateType *)gif->Private)->Read
+ ? ((GifFilePrivateType *)gif->Private)->Read(gif, buf, len)
+ : fread(buf, 1, len,
+ ((GifFilePrivateType *)gif->Private)->File));
}
static int DGifGetWord(GifFileType *GifFile, GifWord *Word);
static int DGifSetupDecompress(GifFileType *GifFile);
static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line,
int LineLen);
-static int DGifGetPrefixChar(GifPrefixType *Prefix, int Code, int ClearCode);
+static int DGifGetPrefixChar(const GifPrefixType *Prefix, int Code,
+ int ClearCode);
static int DGifDecompressInput(GifFileType *GifFile, int *Code);
static int DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf,
GifByteType *NextByte);
@@ -76,15 +77,14 @@ static int DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf,
Returns dynamically allocated GifFileType pointer which serves as the GIF
info record.
******************************************************************************/
-GifFileType *
-DGifOpenFileName(const char *FileName, int *Error)
-{
+GifFileType *DGifOpenFileName(const char *FileName, int *Error) {
int FileHandle;
GifFileType *GifFile;
if ((FileHandle = open(FileName, O_RDONLY)) == -1) {
- if (Error != NULL)
+ if (Error != NULL) {
*Error = D_GIF_ERR_OPEN_FAILED;
+ }
return NULL;
}
@@ -97,9 +97,7 @@ DGifOpenFileName(const char *FileName, int *Error)
Returns dynamically allocated GifFileType pointer which serves as the GIF
info record.
******************************************************************************/
-GifFileType *
-DGifOpenFileHandle(int FileHandle, int *Error)
-{
+GifFileType *DGifOpenFileHandle(int FileHandle, int *Error) {
char Buf[GIF_STAMP_LEN + 1];
GifFileType *GifFile;
GifFilePrivateType *Private;
@@ -107,13 +105,14 @@ DGifOpenFileHandle(int FileHandle, int *Error)
GifFile = (GifFileType *)malloc(sizeof(GifFileType));
if (GifFile == NULL) {
- if (Error != NULL)
+ if (Error != NULL) {
*Error = D_GIF_ERR_NOT_ENOUGH_MEM;
+ }
(void)close(FileHandle);
return NULL;
}
- /*@i1@*/memset(GifFile, '\0', sizeof(GifFileType));
+ /*@i1@*/ memset(GifFile, '\0', sizeof(GifFileType));
/* Belt and suspenders, in case the null pointer isn't zero */
GifFile->SavedImages = NULL;
@@ -121,35 +120,38 @@ DGifOpenFileHandle(int FileHandle, int *Error)
Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType));
if (Private == NULL) {
- if (Error != NULL)
+ if (Error != NULL) {
*Error = D_GIF_ERR_NOT_ENOUGH_MEM;
+ }
(void)close(FileHandle);
free((char *)GifFile);
return NULL;
}
- /*@i1@*/memset(Private, '\0', sizeof(GifFilePrivateType));
+ /*@i1@*/ memset(Private, '\0', sizeof(GifFilePrivateType));
#ifdef _WIN32
- _setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */
-#endif /* _WIN32 */
+ _setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */
+#endif /* _WIN32 */
- f = fdopen(FileHandle, "rb"); /* Make it into a stream: */
+ f = fdopen(FileHandle, "rb"); /* Make it into a stream: */
/*@-mustfreeonly@*/
GifFile->Private = (void *)Private;
Private->FileHandle = FileHandle;
Private->File = f;
Private->FileState = FILE_STATE_READ;
- Private->Read = NULL; /* don't use alternate input method (TVT) */
- GifFile->UserData = NULL; /* TVT */
+ Private->Read = NULL; /* don't use alternate input method (TVT) */
+ GifFile->UserData = NULL; /* TVT */
/*@=mustfreeonly@*/
/* Let's see if this is a GIF file: */
/* coverity[check_return] */
- if (InternalRead(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) {
- if (Error != NULL)
+ if (InternalRead(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) !=
+ GIF_STAMP_LEN) {
+ if (Error != NULL) {
*Error = D_GIF_ERR_READ_FAILED;
+ }
(void)fclose(f);
free((char *)Private);
free((char *)GifFile);
@@ -159,8 +161,9 @@ DGifOpenFileHandle(int FileHandle, int *Error)
/* Check for GIF prefix at start of file */
Buf[GIF_STAMP_LEN] = 0;
if (strncmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) {
- if (Error != NULL)
+ if (Error != NULL) {
*Error = D_GIF_ERR_NOT_GIF_FILE;
+ }
(void)fclose(f);
free((char *)Private);
free((char *)GifFile);
@@ -177,7 +180,7 @@ DGifOpenFileHandle(int FileHandle, int *Error)
GifFile->Error = 0;
/* What version of GIF? */
- Private->gif89 = (Buf[GIF_VERSION_POS] == '9');
+ Private->gif89 = (Buf[GIF_VERSION_POS + 1] == '9');
return GifFile;
}
@@ -185,17 +188,16 @@ DGifOpenFileHandle(int FileHandle, int *Error)
/******************************************************************************
GifFileType constructor with user supplied input function (TVT)
******************************************************************************/
-GifFileType *
-DGifOpen(void *userData, InputFunc readFunc, int *Error)
-{
+GifFileType *DGifOpen(void *userData, InputFunc readFunc, int *Error) {
char Buf[GIF_STAMP_LEN + 1];
GifFileType *GifFile;
GifFilePrivateType *Private;
GifFile = (GifFileType *)malloc(sizeof(GifFileType));
if (GifFile == NULL) {
- if (Error != NULL)
+ if (Error != NULL) {
*Error = D_GIF_ERR_NOT_ENOUGH_MEM;
+ }
return NULL;
}
@@ -207,26 +209,29 @@ DGifOpen(void *userData, InputFunc readFunc, int *Error)
Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType));
if (!Private) {
- if (Error != NULL)
+ if (Error != NULL) {
*Error = D_GIF_ERR_NOT_ENOUGH_MEM;
+ }
free((char *)GifFile);
return NULL;
}
- /*@i1@*/memset(Private, '\0', sizeof(GifFilePrivateType));
+ /*@i1@*/ memset(Private, '\0', sizeof(GifFilePrivateType));
GifFile->Private = (void *)Private;
Private->FileHandle = 0;
Private->File = NULL;
Private->FileState = FILE_STATE_READ;
- Private->Read = readFunc; /* TVT */
- GifFile->UserData = userData; /* TVT */
+ Private->Read = readFunc; /* TVT */
+ GifFile->UserData = userData; /* TVT */
/* Lets see if this is a GIF file: */
/* coverity[check_return] */
- if (InternalRead(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) {
- if (Error != NULL)
+ if (InternalRead(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) !=
+ GIF_STAMP_LEN) {
+ if (Error != NULL) {
*Error = D_GIF_ERR_READ_FAILED;
+ }
free((char *)Private);
free((char *)GifFile);
return NULL;
@@ -235,8 +240,9 @@ DGifOpen(void *userData, InputFunc readFunc, int *Error)
/* Check for GIF prefix at start of file */
Buf[GIF_STAMP_LEN] = '\0';
if (strncmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) {
- if (Error != NULL)
+ if (Error != NULL) {
*Error = D_GIF_ERR_NOT_GIF_FILE;
+ }
free((char *)Private);
free((char *)GifFile);
return NULL;
@@ -245,15 +251,16 @@ DGifOpen(void *userData, InputFunc readFunc, int *Error)
if (DGifGetScreenDesc(GifFile) == GIF_ERROR) {
free((char *)Private);
free((char *)GifFile);
- if (Error != NULL)
+ if (Error != NULL) {
*Error = D_GIF_ERR_NO_SCRN_DSCR;
+ }
return NULL;
}
GifFile->Error = 0;
/* What version of GIF? */
- Private->gif89 = (Buf[GIF_VERSION_POS] == '9');
+ Private->gif89 = (Buf[GIF_VERSION_POS + 1] == '9');
return GifFile;
}
@@ -262,9 +269,7 @@ DGifOpen(void *userData, InputFunc readFunc, int *Error)
This routine should be called before any other DGif calls. Note that
this routine is called automatically from DGif file open routines.
******************************************************************************/
-int
-DGifGetScreenDesc(GifFileType *GifFile)
-{
+int DGifGetScreenDesc(GifFileType *GifFile) {
int BitsPerPixel;
bool SortFlag;
GifByteType Buf[3];
@@ -278,8 +283,9 @@ DGifGetScreenDesc(GifFileType *GifFile)
/* Put the screen descriptor into the file: */
if (DGifGetWord(GifFile, &GifFile->SWidth) == GIF_ERROR ||
- DGifGetWord(GifFile, &GifFile->SHeight) == GIF_ERROR)
+ DGifGetWord(GifFile, &GifFile->SHeight) == GIF_ERROR) {
return GIF_ERROR;
+ }
if (InternalRead(GifFile, Buf, 3) != 3) {
GifFile->Error = D_GIF_ERR_READ_FAILED;
@@ -292,7 +298,7 @@ DGifGetScreenDesc(GifFileType *GifFile)
BitsPerPixel = (Buf[0] & 0x07) + 1;
GifFile->SBackGroundColor = Buf[1];
GifFile->AspectByte = Buf[2];
- if (Buf[0] & 0x80) { /* Do we have global color map? */
+ if (Buf[0] & 0x80) { /* Do we have global color map? */
int i;
GifFile->SColorMap = GifMakeMapObject(1 << BitsPerPixel, NULL);
@@ -327,23 +333,20 @@ DGifGetScreenDesc(GifFileType *GifFile)
return GIF_OK;
}
-const char *
-DGifGetGifVersion(GifFileType *GifFile)
-{
- GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
+const char *DGifGetGifVersion(GifFileType *GifFile) {
+ GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
- if (Private->gif89)
+ if (Private->gif89) {
return GIF89_STAMP;
- else
+ } else {
return GIF87_STAMP;
+ }
}
/******************************************************************************
This routine should be called before any attempt to read an image.
******************************************************************************/
-int
-DGifGetRecordType(GifFileType *GifFile, GifRecordType* Type)
-{
+int DGifGetRecordType(GifFileType *GifFile, GifRecordType *Type) {
GifByteType Buf;
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
@@ -359,29 +362,27 @@ DGifGetRecordType(GifFileType *GifFile, GifRecordType* Type)
return GIF_ERROR;
}
- //fprintf(stderr, "### DGifGetRecordType: %02x\n", Buf);
+ // fprintf(stderr, "### DGifGetRecordType: %02x\n", Buf);
switch (Buf) {
- case DESCRIPTOR_INTRODUCER:
- *Type = IMAGE_DESC_RECORD_TYPE;
- break;
- case EXTENSION_INTRODUCER:
- *Type = EXTENSION_RECORD_TYPE;
- break;
- case TERMINATOR_INTRODUCER:
- *Type = TERMINATE_RECORD_TYPE;
- break;
- default:
- *Type = UNDEFINED_RECORD_TYPE;
- GifFile->Error = D_GIF_ERR_WRONG_RECORD;
- return GIF_ERROR;
+ case DESCRIPTOR_INTRODUCER:
+ *Type = IMAGE_DESC_RECORD_TYPE;
+ break;
+ case EXTENSION_INTRODUCER:
+ *Type = EXTENSION_RECORD_TYPE;
+ break;
+ case TERMINATOR_INTRODUCER:
+ *Type = TERMINATE_RECORD_TYPE;
+ break;
+ default:
+ *Type = UNDEFINED_RECORD_TYPE;
+ GifFile->Error = D_GIF_ERR_WRONG_RECORD;
+ return GIF_ERROR;
}
return GIF_OK;
}
-int
-DGifGetImageHeader(GifFileType *GifFile)
-{
+int DGifGetImageHeader(GifFileType *GifFile) {
unsigned int BitsPerPixel;
GifByteType Buf[3];
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
@@ -395,8 +396,9 @@ DGifGetImageHeader(GifFileType *GifFile)
if (DGifGetWord(GifFile, &GifFile->Image.Left) == GIF_ERROR ||
DGifGetWord(GifFile, &GifFile->Image.Top) == GIF_ERROR ||
DGifGetWord(GifFile, &GifFile->Image.Width) == GIF_ERROR ||
- DGifGetWord(GifFile, &GifFile->Image.Height) == GIF_ERROR)
+ DGifGetWord(GifFile, &GifFile->Image.Height) == GIF_ERROR) {
return GIF_ERROR;
+ }
if (InternalRead(GifFile, Buf, 1) != 1) {
GifFile->Error = D_GIF_ERR_READ_FAILED;
GifFreeMapObject(GifFile->Image.ColorMap);
@@ -415,7 +417,8 @@ DGifGetImageHeader(GifFileType *GifFile)
if (Buf[0] & 0x80) {
unsigned int i;
- GifFile->Image.ColorMap = GifMakeMapObject(1 << BitsPerPixel, NULL);
+ GifFile->Image.ColorMap =
+ GifMakeMapObject(1 << BitsPerPixel, NULL);
if (GifFile->Image.ColorMap == NULL) {
GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
return GIF_ERROR;
@@ -436,8 +439,8 @@ DGifGetImageHeader(GifFileType *GifFile)
}
}
- Private->PixelCount = (long)GifFile->Image.Width *
- (long)GifFile->Image.Height;
+ Private->PixelCount =
+ (long)GifFile->Image.Width * (long)GifFile->Image.Height;
/* Reset decompress algorithm parameters. */
return DGifSetupDecompress(GifFile);
@@ -447,9 +450,7 @@ DGifGetImageHeader(GifFileType *GifFile)
This routine should be called before any attempt to read an image.
Note it is assumed the Image desc. header has been read.
******************************************************************************/
-int
-DGifGetImageDesc(GifFileType *GifFile)
-{
+int DGifGetImageDesc(GifFileType *GifFile) {
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
SavedImage *sp;
@@ -464,9 +465,9 @@ DGifGetImageDesc(GifFileType *GifFile)
}
if (GifFile->SavedImages) {
- SavedImage* new_saved_images =
- (SavedImage *)reallocarray(GifFile->SavedImages,
- (GifFile->ImageCount + 1), sizeof(SavedImage));
+ SavedImage *new_saved_images = (SavedImage *)reallocarray(
+ GifFile->SavedImages, (GifFile->ImageCount + 1),
+ sizeof(SavedImage));
if (new_saved_images == NULL) {
GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
return GIF_ERROR;
@@ -474,7 +475,7 @@ DGifGetImageDesc(GifFileType *GifFile)
GifFile->SavedImages = new_saved_images;
} else {
if ((GifFile->SavedImages =
- (SavedImage *) malloc(sizeof(SavedImage))) == NULL) {
+ (SavedImage *)malloc(sizeof(SavedImage))) == NULL) {
GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
return GIF_ERROR;
}
@@ -483,9 +484,9 @@ DGifGetImageDesc(GifFileType *GifFile)
sp = &GifFile->SavedImages[GifFile->ImageCount];
memcpy(&sp->ImageDesc, &GifFile->Image, sizeof(GifImageDesc));
if (GifFile->Image.ColorMap != NULL) {
- sp->ImageDesc.ColorMap = GifMakeMapObject(
- GifFile->Image.ColorMap->ColorCount,
- GifFile->Image.ColorMap->Colors);
+ sp->ImageDesc.ColorMap =
+ GifMakeMapObject(GifFile->Image.ColorMap->ColorCount,
+ GifFile->Image.ColorMap->Colors);
if (sp->ImageDesc.ColorMap == NULL) {
GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
return GIF_ERROR;
@@ -493,7 +494,7 @@ DGifGetImageDesc(GifFileType *GifFile)
}
sp->RasterBits = (unsigned char *)NULL;
sp->ExtensionBlockCount = 0;
- sp->ExtensionBlocks = (ExtensionBlock *) NULL;
+ sp->ExtensionBlocks = (ExtensionBlock *)NULL;
GifFile->ImageCount++;
@@ -503,11 +504,9 @@ DGifGetImageDesc(GifFileType *GifFile)
/******************************************************************************
Get one full scanned line (Line) of length LineLen from GIF file.
******************************************************************************/
-int
-DGifGetLine(GifFileType *GifFile, GifPixelType *Line, int LineLen)
-{
+int DGifGetLine(GifFileType *GifFile, GifPixelType *Line, int LineLen) {
GifByteType *Dummy;
- GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
+ GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
if (!IS_READABLE(Private)) {
/* This file was NOT open for reading: */
@@ -515,8 +514,9 @@ DGifGetLine(GifFileType *GifFile, GifPixelType *Line, int LineLen)
return GIF_ERROR;
}
- if (!LineLen)
+ if (!LineLen) {
LineLen = GifFile->Image.Width;
+ }
if ((Private->PixelCount -= LineLen) > 0xffff0000UL) {
GifFile->Error = D_GIF_ERR_DATA_TOO_BIG;
@@ -525,56 +525,59 @@ DGifGetLine(GifFileType *GifFile, GifPixelType *Line, int LineLen)
if (DGifDecompressLine(GifFile, Line, LineLen) == GIF_OK) {
if (Private->PixelCount == 0) {
- /* We probably won't be called any more, so let's clean up
- * everything before we return: need to flush out all the
- * rest of image until an empty block (size 0)
+ /* We probably won't be called any more, so let's clean
+ * up everything before we return: need to flush out all
+ * the rest of image until an empty block (size 0)
* detected. We use GetCodeNext.
*/
- do
- if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR)
+ do {
+ if (DGifGetCodeNext(GifFile, &Dummy) ==
+ GIF_ERROR) {
return GIF_ERROR;
- while (Dummy != NULL) ;
+ }
+ } while (Dummy != NULL);
}
return GIF_OK;
- } else
+ } else {
return GIF_ERROR;
+ }
}
/******************************************************************************
Put one pixel (Pixel) into GIF file.
******************************************************************************/
-int
-DGifGetPixel(GifFileType *GifFile, GifPixelType Pixel)
-{
+int DGifGetPixel(GifFileType *GifFile, GifPixelType Pixel) {
GifByteType *Dummy;
- GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
+ GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
if (!IS_READABLE(Private)) {
/* This file was NOT open for reading: */
GifFile->Error = D_GIF_ERR_NOT_READABLE;
return GIF_ERROR;
}
- if (--Private->PixelCount > 0xffff0000UL)
- {
+ if (--Private->PixelCount > 0xffff0000UL) {
GifFile->Error = D_GIF_ERR_DATA_TOO_BIG;
return GIF_ERROR;
}
if (DGifDecompressLine(GifFile, &Pixel, 1) == GIF_OK) {
if (Private->PixelCount == 0) {
- /* We probably won't be called any more, so let's clean up
- * everything before we return: need to flush out all the
- * rest of image until an empty block (size 0)
+ /* We probably won't be called any more, so let's clean
+ * up everything before we return: need to flush out all
+ * the rest of image until an empty block (size 0)
* detected. We use GetCodeNext.
*/
- do
- if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR)
+ do {
+ if (DGifGetCodeNext(GifFile, &Dummy) ==
+ GIF_ERROR) {
return GIF_ERROR;
- while (Dummy != NULL) ;
+ }
+ } while (Dummy != NULL);
}
return GIF_OK;
- } else
+ } else {
return GIF_ERROR;
+ }
}
/******************************************************************************
@@ -584,13 +587,12 @@ DGifGetPixel(GifFileType *GifFile, GifPixelType Pixel)
The Extension should NOT be freed by the user (not dynamically allocated).
Note it is assumed the Extension description header has been read.
******************************************************************************/
-int
-DGifGetExtension(GifFileType *GifFile, int *ExtCode, GifByteType **Extension)
-{
+int DGifGetExtension(GifFileType *GifFile, int *ExtCode,
+ GifByteType **Extension) {
GifByteType Buf;
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
- //fprintf(stderr, "### -> DGifGetExtension:\n");
+ // fprintf(stderr, "### -> DGifGetExtension:\n");
if (!IS_READABLE(Private)) {
/* This file was NOT open for reading: */
GifFile->Error = D_GIF_ERR_NOT_READABLE;
@@ -603,7 +605,8 @@ DGifGetExtension(GifFileType *GifFile, int *ExtCode, GifByteType **Extension)
return GIF_ERROR;
}
*ExtCode = Buf;
- //fprintf(stderr, "### <- DGifGetExtension: %02x, about to call next\n", Buf);
+ // fprintf(stderr, "### <- DGifGetExtension: %02x, about to call
+ // next\n", Buf);
return DGifGetExtensionNext(GifFile, Extension);
}
@@ -613,30 +616,30 @@ DGifGetExtension(GifFileType *GifFile, int *ExtCode, GifByteType **Extension)
routine should be called until NULL Extension is returned.
The Extension should NOT be freed by the user (not dynamically allocated).
******************************************************************************/
-int
-DGifGetExtensionNext(GifFileType *GifFile, GifByteType ** Extension)
-{
+int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **Extension) {
GifByteType Buf;
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
- //fprintf(stderr, "### -> DGifGetExtensionNext\n");
+ // fprintf(stderr, "### -> DGifGetExtensionNext\n");
if (InternalRead(GifFile, &Buf, 1) != 1) {
GifFile->Error = D_GIF_ERR_READ_FAILED;
return GIF_ERROR;
}
- //fprintf(stderr, "### DGifGetExtensionNext sees %d\n", Buf);
+ // fprintf(stderr, "### DGifGetExtensionNext sees %d\n", Buf);
if (Buf > 0) {
- *Extension = Private->Buf; /* Use private unused buffer. */
- (*Extension)[0] = Buf; /* Pascal strings notation (pos. 0 is len.). */
- /* coverity[tainted_data,check_return] */
+ *Extension = Private->Buf; /* Use private unused buffer. */
+ (*Extension)[0] =
+ Buf; /* Pascal strings notation (pos. 0 is len.). */
+ /* coverity[tainted_data,check_return] */
if (InternalRead(GifFile, &((*Extension)[1]), Buf) != Buf) {
GifFile->Error = D_GIF_ERR_READ_FAILED;
return GIF_ERROR;
}
- } else
+ } else {
*Extension = NULL;
- //fprintf(stderr, "### <- DGifGetExtensionNext: %p\n", Extension);
+ }
+ // fprintf(stderr, "### <- DGifGetExtensionNext: %p\n", Extension);
return GIF_OK;
}
@@ -647,19 +650,20 @@ DGifGetExtensionNext(GifFileType *GifFile, GifByteType ** Extension)
int DGifExtensionToGCB(const size_t GifExtensionLength,
const GifByteType *GifExtension,
- GraphicsControlBlock *GCB)
-{
+ GraphicsControlBlock *GCB) {
if (GifExtensionLength != 4) {
return GIF_ERROR;
}
GCB->DisposalMode = (GifExtension[0] >> 2) & 0x07;
GCB->UserInputFlag = (GifExtension[0] & 0x02) != 0;
- GCB->DelayTime = UNSIGNED_LITTLE_ENDIAN(GifExtension[1], GifExtension[2]);
- if (GifExtension[0] & 0x01)
+ GCB->DelayTime =
+ UNSIGNED_LITTLE_ENDIAN(GifExtension[1], GifExtension[2]);
+ if (GifExtension[0] & 0x01) {
GCB->TransparentColor = (int)GifExtension[3];
- else
+ } else {
GCB->TransparentColor = NO_TRANSPARENT_COLOR;
+ }
return GIF_OK;
}
@@ -668,23 +672,27 @@ int DGifExtensionToGCB(const size_t GifExtensionLength,
Extract the Graphics Control Block for a saved image, if it exists.
******************************************************************************/
-int DGifSavedExtensionToGCB(GifFileType *GifFile,
- int ImageIndex, GraphicsControlBlock *GCB)
-{
+int DGifSavedExtensionToGCB(GifFileType *GifFile, int ImageIndex,
+ GraphicsControlBlock *GCB) {
int i;
- if (ImageIndex < 0 || ImageIndex > GifFile->ImageCount - 1)
+ if (ImageIndex < 0 || ImageIndex > GifFile->ImageCount - 1) {
return GIF_ERROR;
+ }
GCB->DisposalMode = DISPOSAL_UNSPECIFIED;
GCB->UserInputFlag = false;
GCB->DelayTime = 0;
GCB->TransparentColor = NO_TRANSPARENT_COLOR;
- for (i = 0; i < GifFile->SavedImages[ImageIndex].ExtensionBlockCount; i++) {
- ExtensionBlock *ep = &GifFile->SavedImages[ImageIndex].ExtensionBlocks[i];
- if (ep->Function == GRAPHICS_EXT_FUNC_CODE)
- return DGifExtensionToGCB(ep->ByteCount, ep->Bytes, GCB);
+ for (i = 0; i < GifFile->SavedImages[ImageIndex].ExtensionBlockCount;
+ i++) {
+ ExtensionBlock *ep =
+ &GifFile->SavedImages[ImageIndex].ExtensionBlocks[i];
+ if (ep->Function == GRAPHICS_EXT_FUNC_CODE) {
+ return DGifExtensionToGCB(ep->ByteCount, ep->Bytes,
+ GCB);
+ }
}
return GIF_ERROR;
@@ -693,13 +701,12 @@ int DGifSavedExtensionToGCB(GifFileType *GifFile,
/******************************************************************************
This routine should be called last, to close the GIF file.
******************************************************************************/
-int
-DGifCloseFile(GifFileType *GifFile, int *ErrorCode)
-{
+int DGifCloseFile(GifFileType *GifFile, int *ErrorCode) {
GifFilePrivateType *Private;
- if (GifFile == NULL || GifFile->Private == NULL)
+ if (GifFile == NULL || GifFile->Private == NULL) {
return GIF_ERROR;
+ }
if (GifFile->Image.ColorMap) {
GifFreeMapObject(GifFile->Image.ColorMap);
@@ -716,22 +723,25 @@ DGifCloseFile(GifFileType *GifFile, int *ErrorCode)
GifFile->SavedImages = NULL;
}
- GifFreeExtensions(&GifFile->ExtensionBlockCount, &GifFile->ExtensionBlocks);
+ GifFreeExtensions(&GifFile->ExtensionBlockCount,
+ &GifFile->ExtensionBlocks);
- Private = (GifFilePrivateType *) GifFile->Private;
+ Private = (GifFilePrivateType *)GifFile->Private;
if (!IS_READABLE(Private)) {
/* This file was NOT open for reading: */
- if (ErrorCode != NULL)
+ if (ErrorCode != NULL) {
*ErrorCode = D_GIF_ERR_NOT_READABLE;
+ }
free((char *)GifFile->Private);
free(GifFile);
return GIF_ERROR;
}
if (Private->File && (fclose(Private->File) != 0)) {
- if (ErrorCode != NULL)
+ if (ErrorCode != NULL) {
*ErrorCode = D_GIF_ERR_CLOSE_FAILED;
+ }
free((char *)GifFile->Private);
free(GifFile);
return GIF_ERROR;
@@ -739,17 +749,16 @@ DGifCloseFile(GifFileType *GifFile, int *ErrorCode)
free((char *)GifFile->Private);
free(GifFile);
- if (ErrorCode != NULL)
+ if (ErrorCode != NULL) {
*ErrorCode = D_GIF_SUCCEEDED;
+ }
return GIF_OK;
}
/******************************************************************************
Get 2 bytes (word) from the given file:
******************************************************************************/
-static int
-DGifGetWord(GifFileType *GifFile, GifWord *Word)
-{
+static int DGifGetWord(GifFileType *GifFile, GifWord *Word) {
unsigned char c[2];
/* coverity[check_return] */
@@ -769,9 +778,7 @@ DGifGetWord(GifFileType *GifFile, GifWord *Word)
to DGifGetCodeNext, until NULL block is returned.
The block should NOT be freed by the user (not dynamically allocated).
******************************************************************************/
-int
-DGifGetCode(GifFileType *GifFile, int *CodeSize, GifByteType **CodeBlock)
-{
+int DGifGetCode(GifFileType *GifFile, int *CodeSize, GifByteType **CodeBlock) {
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
if (!IS_READABLE(Private)) {
@@ -790,9 +797,7 @@ DGifGetCode(GifFileType *GifFile, int *CodeSize, GifByteType **CodeBlock)
called until NULL block is returned.
The block should NOT be freed by the user (not dynamically allocated).
******************************************************************************/
-int
-DGifGetCodeNext(GifFileType *GifFile, GifByteType **CodeBlock)
-{
+int DGifGetCodeNext(GifFileType *GifFile, GifByteType **CodeBlock) {
GifByteType Buf;
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
@@ -805,17 +810,19 @@ DGifGetCodeNext(GifFileType *GifFile, GifByteType **CodeBlock)
/* coverity[lower_bounds] */
if (Buf > 0) {
- *CodeBlock = Private->Buf; /* Use private unused buffer. */
- (*CodeBlock)[0] = Buf; /* Pascal strings notation (pos. 0 is len.). */
- /* coverity[tainted_data] */
+ *CodeBlock = Private->Buf; /* Use private unused buffer. */
+ (*CodeBlock)[0] =
+ Buf; /* Pascal strings notation (pos. 0 is len.). */
+ /* coverity[tainted_data] */
if (InternalRead(GifFile, &((*CodeBlock)[1]), Buf) != Buf) {
GifFile->Error = D_GIF_ERR_READ_FAILED;
return GIF_ERROR;
}
} else {
*CodeBlock = NULL;
- Private->Buf[0] = 0; /* Make sure the buffer is empty! */
- Private->PixelCount = 0; /* And local info. indicate image read. */
+ Private->Buf[0] = 0; /* Make sure the buffer is empty! */
+ Private->PixelCount =
+ 0; /* And local info. indicate image read. */
}
return GIF_OK;
@@ -824,41 +831,43 @@ DGifGetCodeNext(GifFileType *GifFile, GifByteType **CodeBlock)
/******************************************************************************
Setup the LZ decompression for this image:
******************************************************************************/
-static int
-DGifSetupDecompress(GifFileType *GifFile)
-{
+static int DGifSetupDecompress(GifFileType *GifFile) {
int i, BitsPerPixel;
GifByteType CodeSize;
GifPrefixType *Prefix;
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
/* coverity[check_return] */
- if (InternalRead(GifFile, &CodeSize, 1) < 1) { /* Read Code size from file. */
- return GIF_ERROR; /* Failed to read Code size. */
+ if (InternalRead(GifFile, &CodeSize, 1) <
+ 1) { /* Read Code size from file. */
+ GifFile->Error = D_GIF_ERR_READ_FAILED;
+ return GIF_ERROR; /* Failed to read Code size. */
}
BitsPerPixel = CodeSize;
/* this can only happen on a severely malformed GIF */
if (BitsPerPixel > 8) {
- GifFile->Error = D_GIF_ERR_READ_FAILED; /* somewhat bogus error code */
- return GIF_ERROR; /* Failed to read Code size. */
+ GifFile->Error =
+ D_GIF_ERR_READ_FAILED; /* somewhat bogus error code */
+ return GIF_ERROR; /* Failed to read Code size. */
}
- Private->Buf[0] = 0; /* Input Buffer empty. */
+ Private->Buf[0] = 0; /* Input Buffer empty. */
Private->BitsPerPixel = BitsPerPixel;
Private->ClearCode = (1 << BitsPerPixel);
Private->EOFCode = Private->ClearCode + 1;
Private->RunningCode = Private->EOFCode + 1;
- Private->RunningBits = BitsPerPixel + 1; /* Number of bits per code. */
- Private->MaxCode1 = 1 << Private->RunningBits; /* Max. code + 1. */
- Private->StackPtr = 0; /* No pixels on the pixel stack. */
+ Private->RunningBits = BitsPerPixel + 1; /* Number of bits per code. */
+ Private->MaxCode1 = 1 << Private->RunningBits; /* Max. code + 1. */
+ Private->StackPtr = 0; /* No pixels on the pixel stack. */
Private->LastCode = NO_SUCH_CODE;
- Private->CrntShiftState = 0; /* No information in CrntShiftDWord. */
+ Private->CrntShiftState = 0; /* No information in CrntShiftDWord. */
Private->CrntShiftDWord = 0;
Prefix = Private->Prefix;
- for (i = 0; i <= LZ_MAX_CODE; i++)
+ for (i = 0; i <= LZ_MAX_CODE; i++) {
Prefix[i] = NO_SUCH_CODE;
+ }
return GIF_OK;
}
@@ -869,14 +878,13 @@ DGifSetupDecompress(GifFileType *GifFile)
This routine can be called few times (one per scan line, for example), in
order the complete the whole image.
******************************************************************************/
-static int
-DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line, int LineLen)
-{
+static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line,
+ int LineLen) {
int i = 0;
int j, CrntCode, EOFCode, ClearCode, CrntPrefix, LastCode, StackPtr;
GifByteType *Stack, *Suffix;
GifPrefixType *Prefix;
- GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
+ GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
StackPtr = Private->StackPtr;
Prefix = Private->Prefix;
@@ -891,72 +899,88 @@ DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line, int LineLen)
}
if (StackPtr != 0) {
- /* Let pop the stack off before continueing to read the GIF file: */
- while (StackPtr != 0 && i < LineLen)
+ /* Let pop the stack off before continueing to read the GIF
+ * file: */
+ while (StackPtr != 0 && i < LineLen) {
Line[i++] = Stack[--StackPtr];
+ }
}
- while (i < LineLen) { /* Decode LineLen items. */
- if (DGifDecompressInput(GifFile, &CrntCode) == GIF_ERROR)
+ while (i < LineLen) { /* Decode LineLen items. */
+ if (DGifDecompressInput(GifFile, &CrntCode) == GIF_ERROR) {
return GIF_ERROR;
+ }
if (CrntCode == EOFCode) {
- /* Note however that usually we will not be here as we will stop
- * decoding as soon as we got all the pixel, or EOF code will
- * not be read at all, and DGifGetLine/Pixel clean everything. */
+ /* Note however that usually we will not be here as we
+ * will stop decoding as soon as we got all the pixel,
+ * or EOF code will not be read at all, and
+ * DGifGetLine/Pixel clean everything. */
GifFile->Error = D_GIF_ERR_EOF_TOO_SOON;
return GIF_ERROR;
} else if (CrntCode == ClearCode) {
/* We need to start over again: */
- for (j = 0; j <= LZ_MAX_CODE; j++)
+ for (j = 0; j <= LZ_MAX_CODE; j++) {
Prefix[j] = NO_SUCH_CODE;
+ }
Private->RunningCode = Private->EOFCode + 1;
Private->RunningBits = Private->BitsPerPixel + 1;
Private->MaxCode1 = 1 << Private->RunningBits;
LastCode = Private->LastCode = NO_SUCH_CODE;
} else {
- /* Its regular code - if in pixel range simply add it to output
- * stream, otherwise trace to codes linked list until the prefix
- * is in pixel range: */
+ /* Its regular code - if in pixel range simply add it to
+ * output stream, otherwise trace to codes linked list
+ * until the prefix is in pixel range: */
if (CrntCode < ClearCode) {
- /* This is simple - its pixel scalar, so add it to output: */
+ /* This is simple - its pixel scalar, so add it
+ * to output: */
Line[i++] = CrntCode;
} else {
- /* Its a code to needed to be traced: trace the linked list
- * until the prefix is a pixel, while pushing the suffix
- * pixels on our stack. If we done, pop the stack in reverse
- * (thats what stack is good for!) order to output. */
+ /* Its a code to needed to be traced: trace the
+ * linked list until the prefix is a pixel,
+ * while pushing the suffix pixels on our stack.
+ * If we done, pop the stack in reverse (thats
+ * what stack is good for!) order to output. */
if (Prefix[CrntCode] == NO_SUCH_CODE) {
CrntPrefix = LastCode;
- /* Only allowed if CrntCode is exactly the running code:
- * In that case CrntCode = XXXCode, CrntCode or the
- * prefix code is last code and the suffix char is
- * exactly the prefix of last code! */
- if (CrntCode == Private->RunningCode - 2) {
- Suffix[Private->RunningCode - 2] =
- Stack[StackPtr++] = DGifGetPrefixChar(Prefix,
- LastCode,
- ClearCode);
+ /* Only allowed if CrntCode is exactly
+ * the running code: In that case
+ * CrntCode = XXXCode, CrntCode or the
+ * prefix code is last code and the
+ * suffix char is exactly the prefix of
+ * last code! */
+ if (CrntCode ==
+ Private->RunningCode - 2) {
+ Suffix[Private->RunningCode -
+ 2] = Stack[StackPtr++] =
+ DGifGetPrefixChar(
+ Prefix, LastCode,
+ ClearCode);
} else {
- Suffix[Private->RunningCode - 2] =
- Stack[StackPtr++] = DGifGetPrefixChar(Prefix,
- CrntCode,
- ClearCode);
+ Suffix[Private->RunningCode -
+ 2] = Stack[StackPtr++] =
+ DGifGetPrefixChar(
+ Prefix, CrntCode,
+ ClearCode);
}
- } else
+ } else {
CrntPrefix = CrntCode;
+ }
- /* Now (if image is O.K.) we should not get a NO_SUCH_CODE
- * during the trace. As we might loop forever, in case of
- * defective image, we use StackPtr as loop counter and stop
- * before overflowing Stack[]. */
+ /* Now (if image is O.K.) we should not get a
+ * NO_SUCH_CODE during the trace. As we might
+ * loop forever, in case of defective image, we
+ * use StackPtr as loop counter and stop before
+ * overflowing Stack[]. */
while (StackPtr < LZ_MAX_CODE &&
- CrntPrefix > ClearCode && CrntPrefix <= LZ_MAX_CODE) {
+ CrntPrefix > ClearCode &&
+ CrntPrefix <= LZ_MAX_CODE) {
Stack[StackPtr++] = Suffix[CrntPrefix];
CrntPrefix = Prefix[CrntPrefix];
}
- if (StackPtr >= LZ_MAX_CODE || CrntPrefix > LZ_MAX_CODE) {
+ if (StackPtr >= LZ_MAX_CODE ||
+ CrntPrefix > LZ_MAX_CODE) {
GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
return GIF_ERROR;
}
@@ -964,22 +988,29 @@ DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line, int LineLen)
Stack[StackPtr++] = CrntPrefix;
/* Now lets pop all the stack into output: */
- while (StackPtr != 0 && i < LineLen)
+ while (StackPtr != 0 && i < LineLen) {
Line[i++] = Stack[--StackPtr];
+ }
}
- if (LastCode != NO_SUCH_CODE && Private->RunningCode - 2 < (LZ_MAX_CODE+1) && Prefix[Private->RunningCode - 2] == NO_SUCH_CODE) {
+ if (LastCode != NO_SUCH_CODE &&
+ Private->RunningCode - 2 < (LZ_MAX_CODE + 1) &&
+ Prefix[Private->RunningCode - 2] == NO_SUCH_CODE) {
Prefix[Private->RunningCode - 2] = LastCode;
if (CrntCode == Private->RunningCode - 2) {
- /* Only allowed if CrntCode is exactly the running code:
- * In that case CrntCode = XXXCode, CrntCode or the
- * prefix code is last code and the suffix char is
- * exactly the prefix of last code! */
+ /* Only allowed if CrntCode is exactly
+ * the running code: In that case
+ * CrntCode = XXXCode, CrntCode or the
+ * prefix code is last code and the
+ * suffix char is exactly the prefix of
+ * last code! */
Suffix[Private->RunningCode - 2] =
- DGifGetPrefixChar(Prefix, LastCode, ClearCode);
+ DGifGetPrefixChar(Prefix, LastCode,
+ ClearCode);
} else {
Suffix[Private->RunningCode - 2] =
- DGifGetPrefixChar(Prefix, CrntCode, ClearCode);
+ DGifGetPrefixChar(Prefix, CrntCode,
+ ClearCode);
}
}
LastCode = CrntCode;
@@ -998,9 +1029,8 @@ DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line, int LineLen)
If image is defective, we might loop here forever, so we limit the loops to
the maximum possible if image O.k. - LZ_MAX_CODE times.
******************************************************************************/
-static int
-DGifGetPrefixChar(GifPrefixType *Prefix, int Code, int ClearCode)
-{
+static int DGifGetPrefixChar(const GifPrefixType *Prefix, int Code,
+ int ClearCode) {
int i = 0;
while (Code > ClearCode && i++ <= LZ_MAX_CODE) {
@@ -1016,9 +1046,7 @@ DGifGetPrefixChar(GifPrefixType *Prefix, int Code, int ClearCode)
Interface for accessing the LZ codes directly. Set Code to the real code
(12bits), or to -1 if EOF code is returned.
******************************************************************************/
-int
-DGifGetLZCodes(GifFileType *GifFile, int *Code)
-{
+int DGifGetLZCodes(GifFileType *GifFile, int *Code) {
GifByteType *CodeBlock;
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
@@ -1028,15 +1056,18 @@ DGifGetLZCodes(GifFileType *GifFile, int *Code)
return GIF_ERROR;
}
- if (DGifDecompressInput(GifFile, Code) == GIF_ERROR)
+ if (DGifDecompressInput(GifFile, Code) == GIF_ERROR) {
return GIF_ERROR;
+ }
if (*Code == Private->EOFCode) {
- /* Skip rest of codes (hopefully only NULL terminating block): */
+ /* Skip rest of codes (hopefully only NULL terminating block):
+ */
do {
- if (DGifGetCodeNext(GifFile, &CodeBlock) == GIF_ERROR)
+ if (DGifGetCodeNext(GifFile, &CodeBlock) == GIF_ERROR) {
return GIF_ERROR;
- } while (CodeBlock != NULL) ;
+ }
+ } while (CodeBlock != NULL);
*Code = -1;
} else if (*Code == Private->ClearCode) {
@@ -1055,15 +1086,10 @@ DGifGetLZCodes(GifFileType *GifFile, int *Code)
8 bits (bytes) packets, into the real codes.
Returns GIF_OK if read successfully.
******************************************************************************/
-static int
-DGifDecompressInput(GifFileType *GifFile, int *Code)
-{
+static int DGifDecompressInput(GifFileType *GifFile, int *Code) {
static const unsigned short CodeMasks[] = {
- 0x0000, 0x0001, 0x0003, 0x0007,
- 0x000f, 0x001f, 0x003f, 0x007f,
- 0x00ff, 0x01ff, 0x03ff, 0x07ff,
- 0x0fff
- };
+ 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f,
+ 0x007f, 0x00ff, 0x01ff, 0x03ff, 0x07ff, 0x0fff};
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
@@ -1077,11 +1103,12 @@ DGifDecompressInput(GifFileType *GifFile, int *Code)
while (Private->CrntShiftState < Private->RunningBits) {
/* Needs to get more bytes from input stream for next code: */
- if (DGifBufferedInput(GifFile, Private->Buf, &NextByte) == GIF_ERROR) {
+ if (DGifBufferedInput(GifFile, Private->Buf, &NextByte) ==
+ GIF_ERROR) {
return GIF_ERROR;
}
- Private->CrntShiftDWord |=
- ((unsigned long)NextByte) << Private->CrntShiftState;
+ Private->CrntShiftDWord |= ((unsigned long)NextByte)
+ << Private->CrntShiftState;
Private->CrntShiftState += 8;
}
*Code = Private->CrntShiftDWord & CodeMasks[Private->RunningBits];
@@ -1109,9 +1136,8 @@ DGifDecompressInput(GifFileType *GifFile, int *Code)
The routine returns the next byte from its internal buffer (or read next
block in if buffer empty) and returns GIF_OK if succesful.
******************************************************************************/
-static int
-DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf, GifByteType *NextByte)
-{
+static int DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf,
+ GifByteType *NextByte) {
if (Buf[0] == 0) {
/* Needs to read the next buffer - this one is empty: */
/* coverity[check_return] */
@@ -1120,8 +1146,8 @@ DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf, GifByteType *NextByte)
return GIF_ERROR;
}
/* There shouldn't be any empty data blocks here as the LZW spec
- * says the LZW termination code should come first. Therefore we
- * shouldn't be inside this routine at that point.
+ * says the LZW termination code should come first. Therefore
+ * we shouldn't be inside this routine at that point.
*/
if (Buf[0] == 0) {
GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
@@ -1132,7 +1158,7 @@ DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf, GifByteType *NextByte)
return GIF_ERROR;
}
*NextByte = Buf[1];
- Buf[1] = 2; /* We use now the second place as last char read! */
+ Buf[1] = 2; /* We use now the second place as last char read! */
Buf[0]--;
} else {
*NextByte = Buf[Buf[1]++];
@@ -1142,14 +1168,32 @@ DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf, GifByteType *NextByte)
return GIF_OK;
}
+/******************************************************************************
+ This routine is called in case of error during parsing image. We need to
+ decrease image counter and reallocate memory for saved images. Not decreasing
+ ImageCount may lead to null pointer dereference, because the last element in
+ SavedImages may point to the spoilt image and null pointer buffers.
+*******************************************************************************/
+void DGifDecreaseImageCounter(GifFileType *GifFile) {
+ GifFile->ImageCount--;
+ if (GifFile->SavedImages[GifFile->ImageCount].RasterBits != NULL) {
+ free(GifFile->SavedImages[GifFile->ImageCount].RasterBits);
+ }
+
+ // Realloc array according to the new image counter.
+ SavedImage *correct_saved_images = (SavedImage *)reallocarray(
+ GifFile->SavedImages, GifFile->ImageCount, sizeof(SavedImage));
+ if (correct_saved_images != NULL) {
+ GifFile->SavedImages = correct_saved_images;
+ }
+}
+
/******************************************************************************
This routine reads an entire GIF into core, hanging all its state info off
the GifFileType pointer. Call DGifOpenFileName() or DGifOpenFileHandle()
first to initialize I/O. Its inverse is EGifSpew().
*******************************************************************************/
-int
-DGifSlurp(GifFileType *GifFile)
-{
+int DGifSlurp(GifFileType *GifFile) {
size_t ImageSize;
GifRecordType RecordType;
SavedImage *sp;
@@ -1160,103 +1204,130 @@ DGifSlurp(GifFileType *GifFile)
GifFile->ExtensionBlockCount = 0;
do {
- if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR)
+ if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR) {
return (GIF_ERROR);
+ }
switch (RecordType) {
- case IMAGE_DESC_RECORD_TYPE:
- if (DGifGetImageDesc(GifFile) == GIF_ERROR)
- return (GIF_ERROR);
-
- sp = &GifFile->SavedImages[GifFile->ImageCount - 1];
- /* Allocate memory for the image */
- if (sp->ImageDesc.Width <= 0 || sp->ImageDesc.Height <= 0 ||
- sp->ImageDesc.Width > (INT_MAX / sp->ImageDesc.Height)) {
- return GIF_ERROR;
- }
- ImageSize = sp->ImageDesc.Width * sp->ImageDesc.Height;
-
- if (ImageSize > (SIZE_MAX / sizeof(GifPixelType))) {
- return GIF_ERROR;
- }
- sp->RasterBits = (unsigned char *)reallocarray(NULL, ImageSize,
- sizeof(GifPixelType));
-
- if (sp->RasterBits == NULL) {
- return GIF_ERROR;
- }
-
- if (sp->ImageDesc.Interlace) {
- int i, j;
- /*
- * The way an interlaced image should be read -
- * offsets and jumps...
- */
- int InterlacedOffset[] = { 0, 4, 2, 1 };
- int InterlacedJumps[] = { 8, 8, 4, 2 };
- /* Need to perform 4 passes on the image */
- for (i = 0; i < 4; i++)
- for (j = InterlacedOffset[i];
- j < sp->ImageDesc.Height;
- j += InterlacedJumps[i]) {
- if (DGifGetLine(GifFile,
- sp->RasterBits+j*sp->ImageDesc.Width,
- sp->ImageDesc.Width) == GIF_ERROR)
- return GIF_ERROR;
- }
- }
- else {
- if (DGifGetLine(GifFile,sp->RasterBits,ImageSize)==GIF_ERROR)
- return (GIF_ERROR);
- }
-
- if (GifFile->ExtensionBlocks) {
- sp->ExtensionBlocks = GifFile->ExtensionBlocks;
- sp->ExtensionBlockCount = GifFile->ExtensionBlockCount;
-
- GifFile->ExtensionBlocks = NULL;
- GifFile->ExtensionBlockCount = 0;
- }
- break;
-
- case EXTENSION_RECORD_TYPE:
- if (DGifGetExtension(GifFile,&ExtFunction,&ExtData) == GIF_ERROR)
- return (GIF_ERROR);
- /* Create an extension block with our data */
- if (ExtData != NULL) {
- if (GifAddExtensionBlock(&GifFile->ExtensionBlockCount,
- &GifFile->ExtensionBlocks,
- ExtFunction, ExtData[0], &ExtData[1])
- == GIF_ERROR)
- return (GIF_ERROR);
- }
- for (;;) {
- if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR)
- return (GIF_ERROR);
- if (ExtData == NULL)
- break;
- /* Continue the extension block */
- if (ExtData != NULL)
- if (GifAddExtensionBlock(&GifFile->ExtensionBlockCount,
- &GifFile->ExtensionBlocks,
- CONTINUE_EXT_FUNC_CODE,
- ExtData[0], &ExtData[1]) == GIF_ERROR)
- return (GIF_ERROR);
- }
- break;
-
- case TERMINATE_RECORD_TYPE:
- break;
-
- default: /* Should be trapped by DGifGetRecordType */
- break;
+ case IMAGE_DESC_RECORD_TYPE:
+ if (DGifGetImageDesc(GifFile) == GIF_ERROR) {
+ return (GIF_ERROR);
+ }
+
+ sp = &GifFile->SavedImages[GifFile->ImageCount - 1];
+ /* Allocate memory for the image */
+ if (sp->ImageDesc.Width <= 0 ||
+ sp->ImageDesc.Height <= 0 ||
+ sp->ImageDesc.Width >
+ (INT_MAX / sp->ImageDesc.Height)) {
+ DGifDecreaseImageCounter(GifFile);
+ return GIF_ERROR;
+ }
+ ImageSize = sp->ImageDesc.Width * sp->ImageDesc.Height;
+
+ if (ImageSize > (SIZE_MAX / sizeof(GifPixelType))) {
+ DGifDecreaseImageCounter(GifFile);
+ return GIF_ERROR;
+ }
+ sp->RasterBits = (unsigned char *)reallocarray(
+ NULL, ImageSize, sizeof(GifPixelType));
+
+ if (sp->RasterBits == NULL) {
+ DGifDecreaseImageCounter(GifFile);
+ return GIF_ERROR;
+ }
+
+ if (sp->ImageDesc.Interlace) {
+ int i, j;
+ /*
+ * The way an interlaced image should be read -
+ * offsets and jumps...
+ */
+ static const int InterlacedOffset[] = {0, 4, 2,
+ 1};
+ static const int InterlacedJumps[] = {8, 8, 4,
+ 2};
+ /* Need to perform 4 passes on the image */
+ for (i = 0; i < 4; i++) {
+ for (j = InterlacedOffset[i];
+ j < sp->ImageDesc.Height;
+ j += InterlacedJumps[i]) {
+ if (DGifGetLine(
+ GifFile,
+ sp->RasterBits +
+ j * sp->ImageDesc
+ .Width,
+ sp->ImageDesc.Width) ==
+ GIF_ERROR) {
+ DGifDecreaseImageCounter(
+ GifFile);
+ return GIF_ERROR;
+ }
+ }
+ }
+ } else {
+ if (DGifGetLine(GifFile, sp->RasterBits,
+ ImageSize) == GIF_ERROR) {
+ DGifDecreaseImageCounter(GifFile);
+ return GIF_ERROR;
+ }
+ }
+
+ if (GifFile->ExtensionBlocks) {
+ sp->ExtensionBlocks = GifFile->ExtensionBlocks;
+ sp->ExtensionBlockCount =
+ GifFile->ExtensionBlockCount;
+
+ GifFile->ExtensionBlocks = NULL;
+ GifFile->ExtensionBlockCount = 0;
+ }
+ break;
+
+ case EXTENSION_RECORD_TYPE:
+ if (DGifGetExtension(GifFile, &ExtFunction, &ExtData) ==
+ GIF_ERROR) {
+ return (GIF_ERROR);
+ }
+ /* Create an extension block with our data */
+ if (ExtData != NULL) {
+ if (GifAddExtensionBlock(
+ &GifFile->ExtensionBlockCount,
+ &GifFile->ExtensionBlocks, ExtFunction,
+ ExtData[0], &ExtData[1]) == GIF_ERROR) {
+ return (GIF_ERROR);
+ }
+ }
+ for (;;) {
+ if (DGifGetExtensionNext(GifFile, &ExtData) ==
+ GIF_ERROR) {
+ return (GIF_ERROR);
+ }
+ if (ExtData == NULL) {
+ break;
+ }
+ /* Continue the extension block */
+ if (GifAddExtensionBlock(
+ &GifFile->ExtensionBlockCount,
+ &GifFile->ExtensionBlocks,
+ CONTINUE_EXT_FUNC_CODE, ExtData[0],
+ &ExtData[1]) == GIF_ERROR) {
+ return (GIF_ERROR);
+ }
+ }
+ break;
+
+ case TERMINATE_RECORD_TYPE:
+ break;
+
+ default: /* Should be trapped by DGifGetRecordType */
+ break;
}
} while (RecordType != TERMINATE_RECORD_TYPE);
/* Sanity check for corrupted file */
if (GifFile->ImageCount == 0) {
GifFile->Error = D_GIF_ERR_NO_IMAG_DSCR;
- return(GIF_ERROR);
+ return (GIF_ERROR);
}
return (GIF_OK);
diff --git a/src/java.desktop/share/native/libsplashscreen/giflib/gif_err.c b/src/java.desktop/share/native/libsplashscreen/giflib/gif_err.c
index db08838efff..3b6785f7c63 100644
--- a/src/java.desktop/share/native/libsplashscreen/giflib/gif_err.c
+++ b/src/java.desktop/share/native/libsplashscreen/giflib/gif_err.c
@@ -38,82 +38,80 @@ SPDX-License-Identifier: MIT
/*****************************************************************************
Return a string description of the last GIF error
*****************************************************************************/
-const char *
-GifErrorString(int ErrorCode)
-{
+const char *GifErrorString(int ErrorCode) {
const char *Err;
switch (ErrorCode) {
- case E_GIF_ERR_OPEN_FAILED:
+ case E_GIF_ERR_OPEN_FAILED:
Err = "Failed to open given file";
break;
- case E_GIF_ERR_WRITE_FAILED:
+ case E_GIF_ERR_WRITE_FAILED:
Err = "Failed to write to given file";
break;
- case E_GIF_ERR_HAS_SCRN_DSCR:
+ case E_GIF_ERR_HAS_SCRN_DSCR:
Err = "Screen descriptor has already been set";
break;
- case E_GIF_ERR_HAS_IMAG_DSCR:
+ case E_GIF_ERR_HAS_IMAG_DSCR:
Err = "Image descriptor is still active";
break;
- case E_GIF_ERR_NO_COLOR_MAP:
+ case E_GIF_ERR_NO_COLOR_MAP:
Err = "Neither global nor local color map";
break;
- case E_GIF_ERR_DATA_TOO_BIG:
+ case E_GIF_ERR_DATA_TOO_BIG:
Err = "Number of pixels bigger than width * height";
break;
- case E_GIF_ERR_NOT_ENOUGH_MEM:
+ case E_GIF_ERR_NOT_ENOUGH_MEM:
Err = "Failed to allocate required memory";
break;
- case E_GIF_ERR_DISK_IS_FULL:
+ case E_GIF_ERR_DISK_IS_FULL:
Err = "Write failed (disk full?)";
break;
- case E_GIF_ERR_CLOSE_FAILED:
+ case E_GIF_ERR_CLOSE_FAILED:
Err = "Failed to close given file";
break;
- case E_GIF_ERR_NOT_WRITEABLE:
+ case E_GIF_ERR_NOT_WRITEABLE:
Err = "Given file was not opened for write";
break;
- case D_GIF_ERR_OPEN_FAILED:
+ case D_GIF_ERR_OPEN_FAILED:
Err = "Failed to open given file";
break;
- case D_GIF_ERR_READ_FAILED:
+ case D_GIF_ERR_READ_FAILED:
Err = "Failed to read from given file";
break;
- case D_GIF_ERR_NOT_GIF_FILE:
+ case D_GIF_ERR_NOT_GIF_FILE:
Err = "Data is not in GIF format";
break;
- case D_GIF_ERR_NO_SCRN_DSCR:
+ case D_GIF_ERR_NO_SCRN_DSCR:
Err = "No screen descriptor detected";
break;
- case D_GIF_ERR_NO_IMAG_DSCR:
+ case D_GIF_ERR_NO_IMAG_DSCR:
Err = "No Image Descriptor detected";
break;
- case D_GIF_ERR_NO_COLOR_MAP:
+ case D_GIF_ERR_NO_COLOR_MAP:
Err = "Neither global nor local color map";
break;
- case D_GIF_ERR_WRONG_RECORD:
+ case D_GIF_ERR_WRONG_RECORD:
Err = "Wrong record type detected";
break;
- case D_GIF_ERR_DATA_TOO_BIG:
+ case D_GIF_ERR_DATA_TOO_BIG:
Err = "Number of pixels bigger than width * height";
break;
- case D_GIF_ERR_NOT_ENOUGH_MEM:
+ case D_GIF_ERR_NOT_ENOUGH_MEM:
Err = "Failed to allocate required memory";
break;
- case D_GIF_ERR_CLOSE_FAILED:
+ case D_GIF_ERR_CLOSE_FAILED:
Err = "Failed to close given file";
break;
- case D_GIF_ERR_NOT_READABLE:
+ case D_GIF_ERR_NOT_READABLE:
Err = "Given file was not opened for read";
break;
- case D_GIF_ERR_IMAGE_DEFECT:
+ case D_GIF_ERR_IMAGE_DEFECT:
Err = "Image is defective, decoding aborted";
break;
- case D_GIF_ERR_EOF_TOO_SOON:
+ case D_GIF_ERR_EOF_TOO_SOON:
Err = "Image EOF detected before image complete";
break;
- default:
+ default:
Err = NULL;
break;
}
diff --git a/src/java.desktop/share/native/libsplashscreen/giflib/gif_hash.h b/src/java.desktop/share/native/libsplashscreen/giflib/gif_hash.h
index 6cabd0866ed..bd00af64161 100644
--- a/src/java.desktop/share/native/libsplashscreen/giflib/gif_hash.h
+++ b/src/java.desktop/share/native/libsplashscreen/giflib/gif_hash.h
@@ -33,27 +33,25 @@ SPDX-License-Identifier: MIT
#ifndef _GIF_HASH_H_
#define _GIF_HASH_H_
-/** Begin JDK modifications to support building on Windows **/
#ifndef _WIN32
#include
-#endif
-/** End JDK modifications to support building on Windows **/
+#endif /* _WIN32 */
#include
-#define HT_SIZE 8192 /* 12bits = 4096 or twice as big! */
-#define HT_KEY_MASK 0x1FFF /* 13bits keys */
-#define HT_KEY_NUM_BITS 13 /* 13bits keys */
-#define HT_MAX_KEY 8191 /* 13bits - 1, maximal code possible */
-#define HT_MAX_CODE 4095 /* Biggest code possible in 12 bits. */
+#define HT_SIZE 8192 /* 12bits = 4096 or twice as big! */
+#define HT_KEY_MASK 0x1FFF /* 13bits keys */
+#define HT_KEY_NUM_BITS 13 /* 13bits keys */
+#define HT_MAX_KEY 8191 /* 13bits - 1, maximal code possible */
+#define HT_MAX_CODE 4095 /* Biggest code possible in 12 bits. */
/* The 32 bits of the long are divided into two parts for the key & code: */
/* 1. The code is 12 bits as our compression algorithm is limited to 12bits */
-/* 2. The key is 12 bits Prefix code + 8 bit new char or 20 bits. */
+/* 2. The key is 12 bits Prefix code + 8 bit new char or 20 bits. */
/* The key is the upper 20 bits. The code is the lower 12. */
-#define HT_GET_KEY(l) (l >> 12)
-#define HT_GET_CODE(l) (l & 0x0FFF)
-#define HT_PUT_KEY(l) (l << 12)
-#define HT_PUT_CODE(l) (l & 0x0FFF)
+#define HT_GET_KEY(l) (l >> 12)
+#define HT_GET_CODE(l) (l & 0x0FFF)
+#define HT_PUT_KEY(l) (l << 12)
+#define HT_PUT_CODE(l) (l & 0x0FFF)
typedef struct GifHashTableType {
uint32_t HTable[HT_SIZE];
diff --git a/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h b/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h
index f739b36adfd..74a2e969c0d 100644
--- a/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h
+++ b/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h
@@ -39,27 +39,19 @@ extern "C" {
#define GIFLIB_MAJOR 5
#define GIFLIB_MINOR 2
-#define GIFLIB_RELEASE 1
+#define GIFLIB_RELEASE 2
-#define GIF_ERROR 0
-#define GIF_OK 1
+#define GIF_ERROR 0
+#define GIF_OK 1
+#include
#include
-/** Begin JDK modifications to support building using old compilers**/
-//#include
-#ifdef bool
-#undef bool
-#endif
-typedef int bool;
-#define false 0
-#define true 1
-/** End JDK modifications to support building using old compilers**/
-
-#define GIF_STAMP "GIFVER" /* First chars in file - GIF stamp. */
+
+#define GIF_STAMP "GIFVER" /* First chars in file - GIF stamp. */
#define GIF_STAMP_LEN sizeof(GIF_STAMP) - 1
-#define GIF_VERSION_POS 3 /* Version first character in stamp. */
-#define GIF87_STAMP "GIF87a" /* First chars in file - GIF stamp. */
-#define GIF89_STAMP "GIF89a" /* First chars in file - GIF stamp. */
+#define GIF_VERSION_POS 3 /* Version first character in stamp. */
+#define GIF87_STAMP "GIF87a" /* First chars in file - GIF stamp. */
+#define GIF89_STAMP "GIF89a" /* First chars in file - GIF stamp. */
typedef unsigned char GifPixelType;
typedef unsigned char *GifRowType;
@@ -75,24 +67,24 @@ typedef struct ColorMapObject {
int ColorCount;
int BitsPerPixel;
bool SortFlag;
- GifColorType *Colors; /* on malloc(3) heap */
+ GifColorType *Colors; /* on malloc(3) heap */
} ColorMapObject;
typedef struct GifImageDesc {
- GifWord Left, Top, Width, Height; /* Current image dimensions. */
- bool Interlace; /* Sequential/Interlaced lines. */
- ColorMapObject *ColorMap; /* The local color map */
+ GifWord Left, Top, Width, Height; /* Current image dimensions. */
+ bool Interlace; /* Sequential/Interlaced lines. */
+ ColorMapObject *ColorMap; /* The local color map */
} GifImageDesc;
typedef struct ExtensionBlock {
int ByteCount;
- GifByteType *Bytes; /* on malloc(3) heap */
- int Function; /* The block function code */
-#define CONTINUE_EXT_FUNC_CODE 0x00 /* continuation subblock */
-#define COMMENT_EXT_FUNC_CODE 0xfe /* comment */
-#define GRAPHICS_EXT_FUNC_CODE 0xf9 /* graphics control (GIF89) */
-#define PLAINTEXT_EXT_FUNC_CODE 0x01 /* plaintext */
-#define APPLICATION_EXT_FUNC_CODE 0xff /* application block (GIF89) */
+ GifByteType *Bytes; /* on malloc(3) heap */
+ int Function; /* The block function code */
+#define CONTINUE_EXT_FUNC_CODE 0x00 /* continuation subblock */
+#define COMMENT_EXT_FUNC_CODE 0xfe /* comment */
+#define GRAPHICS_EXT_FUNC_CODE 0xf9 /* graphics control (GIF89) */
+#define PLAINTEXT_EXT_FUNC_CODE 0x01 /* plaintext */
+#define APPLICATION_EXT_FUNC_CODE 0xff /* application block (GIF89) */
} ExtensionBlock;
typedef struct SavedImage {
@@ -103,22 +95,22 @@ typedef struct SavedImage {
} SavedImage;
typedef struct GifFileType {
- GifWord SWidth, SHeight; /* Size of virtual canvas */
- GifWord SColorResolution; /* How many colors can we generate? */
- GifWord SBackGroundColor; /* Background color for virtual canvas */
- GifByteType AspectByte; /* Used to compute pixel aspect ratio */
- ColorMapObject *SColorMap; /* Global colormap, NULL if nonexistent. */
- int ImageCount; /* Number of current image (both APIs) */
- GifImageDesc Image; /* Current image (low-level API) */
- SavedImage *SavedImages; /* Image sequence (high-level API) */
- int ExtensionBlockCount; /* Count extensions past last image */
+ GifWord SWidth, SHeight; /* Size of virtual canvas */
+ GifWord SColorResolution; /* How many colors can we generate? */
+ GifWord SBackGroundColor; /* Background color for virtual canvas */
+ GifByteType AspectByte; /* Used to compute pixel aspect ratio */
+ ColorMapObject *SColorMap; /* Global colormap, NULL if nonexistent. */
+ int ImageCount; /* Number of current image (both APIs) */
+ GifImageDesc Image; /* Current image (low-level API) */
+ SavedImage *SavedImages; /* Image sequence (high-level API) */
+ int ExtensionBlockCount; /* Count extensions past last image */
ExtensionBlock *ExtensionBlocks; /* Extensions past last image */
int Error; /* Last error condition reported */
void *UserData; /* hook to attach user data (TVT) */
void *Private; /* Don't mess with this! */
} GifFileType;
-#define GIF_ASPECT_RATIO(n) ((n)+15.0/64.0)
+#define GIF_ASPECT_RATIO(n) ((n) + 15.0 / 64.0)
typedef enum {
UNDEFINED_RECORD_TYPE,
@@ -129,12 +121,12 @@ typedef enum {
} GifRecordType;
/* func type to read gif data from arbitrary sources (TVT) */
-typedef int (*InputFunc) (GifFileType *, GifByteType *, int);
+typedef int (*InputFunc)(GifFileType *, GifByteType *, int);
/* func type to write gif data to arbitrary targets.
* Returns count of bytes written. (MRB)
*/
-typedef int (*OutputFunc) (GifFileType *, const GifByteType *, int);
+typedef int (*OutputFunc)(GifFileType *, const GifByteType *, int);
/******************************************************************************
GIF89 structures
@@ -142,14 +134,14 @@ typedef int (*OutputFunc) (GifFileType *, const GifByteType *, int);
typedef struct GraphicsControlBlock {
int DisposalMode;
-#define DISPOSAL_UNSPECIFIED 0 /* No disposal specified. */
-#define DISPOSE_DO_NOT 1 /* Leave image in place */
-#define DISPOSE_BACKGROUND 2 /* Set area too background color */
-#define DISPOSE_PREVIOUS 3 /* Restore to previous content */
- bool UserInputFlag; /* User confirmation required before disposal */
- int DelayTime; /* pre-display delay in 0.01sec units */
- int TransparentColor; /* Palette index for transparency, -1 if none */
-#define NO_TRANSPARENT_COLOR -1
+#define DISPOSAL_UNSPECIFIED 0 /* No disposal specified. */
+#define DISPOSE_DO_NOT 1 /* Leave image in place */
+#define DISPOSE_BACKGROUND 2 /* Set area too background color */
+#define DISPOSE_PREVIOUS 3 /* Restore to previous content */
+ bool UserInputFlag; /* User confirmation required before disposal */
+ int DelayTime; /* pre-display delay in 0.01sec units */
+ int TransparentColor; /* Palette index for transparency, -1 if none */
+#define NO_TRANSPARENT_COLOR -1
} GraphicsControlBlock;
/******************************************************************************
@@ -161,49 +153,44 @@ GifFileType *EGifOpenFileName(const char *GifFileName,
const bool GifTestExistence, int *Error);
GifFileType *EGifOpenFileHandle(const int GifFileHandle, int *Error);
GifFileType *EGifOpen(void *userPtr, OutputFunc writeFunc, int *Error);
-int EGifSpew(GifFileType * GifFile);
+int EGifSpew(GifFileType *GifFile);
const char *EGifGetGifVersion(GifFileType *GifFile); /* new in 5.x */
int EGifCloseFile(GifFileType *GifFile, int *ErrorCode);
-#define E_GIF_SUCCEEDED 0
-#define E_GIF_ERR_OPEN_FAILED 1 /* And EGif possible errors. */
-#define E_GIF_ERR_WRITE_FAILED 2
-#define E_GIF_ERR_HAS_SCRN_DSCR 3
-#define E_GIF_ERR_HAS_IMAG_DSCR 4
-#define E_GIF_ERR_NO_COLOR_MAP 5
-#define E_GIF_ERR_DATA_TOO_BIG 6
+#define E_GIF_SUCCEEDED 0
+#define E_GIF_ERR_OPEN_FAILED 1 /* And EGif possible errors. */
+#define E_GIF_ERR_WRITE_FAILED 2
+#define E_GIF_ERR_HAS_SCRN_DSCR 3
+#define E_GIF_ERR_HAS_IMAG_DSCR 4
+#define E_GIF_ERR_NO_COLOR_MAP 5
+#define E_GIF_ERR_DATA_TOO_BIG 6
#define E_GIF_ERR_NOT_ENOUGH_MEM 7
-#define E_GIF_ERR_DISK_IS_FULL 8
-#define E_GIF_ERR_CLOSE_FAILED 9
-#define E_GIF_ERR_NOT_WRITEABLE 10
+#define E_GIF_ERR_DISK_IS_FULL 8
+#define E_GIF_ERR_CLOSE_FAILED 9
+#define E_GIF_ERR_NOT_WRITEABLE 10
/* These are legacy. You probably do not want to call them directly */
-int EGifPutScreenDesc(GifFileType *GifFile,
- const int GifWidth, const int GifHeight,
- const int GifColorRes,
+int EGifPutScreenDesc(GifFileType *GifFile, const int GifWidth,
+ const int GifHeight, const int GifColorRes,
const int GifBackGround,
const ColorMapObject *GifColorMap);
-int EGifPutImageDesc(GifFileType *GifFile,
- const int GifLeft, const int GifTop,
+int EGifPutImageDesc(GifFileType *GifFile, const int GifLeft, const int GifTop,
const int GifWidth, const int GifHeight,
const bool GifInterlace,
const ColorMapObject *GifColorMap);
void EGifSetGifVersion(GifFileType *GifFile, const bool gif89);
-int EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine,
- int GifLineLen);
+int EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen);
int EGifPutPixel(GifFileType *GifFile, const GifPixelType GifPixel);
int EGifPutComment(GifFileType *GifFile, const char *GifComment);
int EGifPutExtensionLeader(GifFileType *GifFile, const int GifExtCode);
-int EGifPutExtensionBlock(GifFileType *GifFile,
- const int GifExtLen, const void *GifExtension);
+int EGifPutExtensionBlock(GifFileType *GifFile, const int GifExtLen,
+ const void *GifExtension);
int EGifPutExtensionTrailer(GifFileType *GifFile);
int EGifPutExtension(GifFileType *GifFile, const int GifExtCode,
- const int GifExtLen,
- const void *GifExtension);
+ const int GifExtLen, const void *GifExtension);
int EGifPutCode(GifFileType *GifFile, int GifCodeSize,
const GifByteType *GifCodeBlock);
-int EGifPutCodeNext(GifFileType *GifFile,
- const GifByteType *GifCodeBlock);
+int EGifPutCodeNext(GifFileType *GifFile, const GifByteType *GifCodeBlock);
/******************************************************************************
GIF decoding routines
@@ -212,24 +199,25 @@ int EGifPutCodeNext(GifFileType *GifFile,
/* Main entry points */
GifFileType *DGifOpenFileName(const char *GifFileName, int *Error);
GifFileType *DGifOpenFileHandle(int GifFileHandle, int *Error);
-int DGifSlurp(GifFileType * GifFile);
-GifFileType *DGifOpen(void *userPtr, InputFunc readFunc, int *Error); /* new one (TVT) */
- int DGifCloseFile(GifFileType * GifFile, int *ErrorCode);
-
-#define D_GIF_SUCCEEDED 0
-#define D_GIF_ERR_OPEN_FAILED 101 /* And DGif possible errors. */
-#define D_GIF_ERR_READ_FAILED 102
-#define D_GIF_ERR_NOT_GIF_FILE 103
-#define D_GIF_ERR_NO_SCRN_DSCR 104
-#define D_GIF_ERR_NO_IMAG_DSCR 105
-#define D_GIF_ERR_NO_COLOR_MAP 106
-#define D_GIF_ERR_WRONG_RECORD 107
-#define D_GIF_ERR_DATA_TOO_BIG 108
+int DGifSlurp(GifFileType *GifFile);
+GifFileType *DGifOpen(void *userPtr, InputFunc readFunc,
+ int *Error); /* new one (TVT) */
+int DGifCloseFile(GifFileType *GifFile, int *ErrorCode);
+
+#define D_GIF_SUCCEEDED 0
+#define D_GIF_ERR_OPEN_FAILED 101 /* And DGif possible errors. */
+#define D_GIF_ERR_READ_FAILED 102
+#define D_GIF_ERR_NOT_GIF_FILE 103
+#define D_GIF_ERR_NO_SCRN_DSCR 104
+#define D_GIF_ERR_NO_IMAG_DSCR 105
+#define D_GIF_ERR_NO_COLOR_MAP 106
+#define D_GIF_ERR_WRONG_RECORD 107
+#define D_GIF_ERR_DATA_TOO_BIG 108
#define D_GIF_ERR_NOT_ENOUGH_MEM 109
-#define D_GIF_ERR_CLOSE_FAILED 110
-#define D_GIF_ERR_NOT_READABLE 111
-#define D_GIF_ERR_IMAGE_DEFECT 112
-#define D_GIF_ERR_EOF_TOO_SOON 113
+#define D_GIF_ERR_CLOSE_FAILED 110
+#define D_GIF_ERR_NOT_READABLE 111
+#define D_GIF_ERR_IMAGE_DEFECT 112
+#define D_GIF_ERR_EOF_TOO_SOON 113
/* These are legacy. You probably do not want to call them directly */
int DGifGetScreenDesc(GifFileType *GifFile);
@@ -247,11 +235,10 @@ int DGifGetCodeNext(GifFileType *GifFile, GifByteType **GifCodeBlock);
int DGifGetLZCodes(GifFileType *GifFile, int *GifCode);
const char *DGifGetGifVersion(GifFileType *GifFile);
-
/******************************************************************************
Error handling and reporting.
******************************************************************************/
-extern const char *GifErrorString(int ErrorCode); /* new in 2012 - ESR */
+extern const char *GifErrorString(int ErrorCode); /* new in 2012 - ESR */
/*****************************************************************************
Everything below this point is new after version 1.2, supporting `slurp
@@ -263,26 +250,26 @@ extern const char *GifErrorString(int ErrorCode); /* new in 2012 - ESR */
******************************************************************************/
extern ColorMapObject *GifMakeMapObject(int ColorCount,
- const GifColorType *ColorMap);
+ const GifColorType *ColorMap);
extern void GifFreeMapObject(ColorMapObject *Object);
extern ColorMapObject *GifUnionColorMap(const ColorMapObject *ColorIn1,
- const ColorMapObject *ColorIn2,
- GifPixelType ColorTransIn2[]);
+ const ColorMapObject *ColorIn2,
+ GifPixelType ColorTransIn2[]);
extern int GifBitSize(int n);
/******************************************************************************
Support for the in-core structures allocation (slurp mode).
******************************************************************************/
-extern void GifApplyTranslation(SavedImage *Image, GifPixelType Translation[]);
+extern void GifApplyTranslation(SavedImage *Image,
+ const GifPixelType Translation[]);
extern int GifAddExtensionBlock(int *ExtensionBlock_Count,
- ExtensionBlock **ExtensionBlocks,
- int Function,
+ ExtensionBlock **ExtensionBlocks, int Function,
unsigned int Len, unsigned char ExtData[]);
extern void GifFreeExtensions(int *ExtensionBlock_Count,
ExtensionBlock **ExtensionBlocks);
extern SavedImage *GifMakeSavedImage(GifFileType *GifFile,
- const SavedImage *CopyFrom);
+ const SavedImage *CopyFrom);
extern void GifFreeSavedImages(GifFileType *GifFile);
/******************************************************************************
@@ -295,37 +282,31 @@ int DGifExtensionToGCB(const size_t GifExtensionLength,
size_t EGifGCBToExtension(const GraphicsControlBlock *GCB,
GifByteType *GifExtension);
-int DGifSavedExtensionToGCB(GifFileType *GifFile,
- int ImageIndex,
+int DGifSavedExtensionToGCB(GifFileType *GifFile, int ImageIndex,
GraphicsControlBlock *GCB);
int EGifGCBToSavedExtension(const GraphicsControlBlock *GCB,
- GifFileType *GifFile,
- int ImageIndex);
+ GifFileType *GifFile, int ImageIndex);
/******************************************************************************
The library's internal utility font
******************************************************************************/
-#define GIF_FONT_WIDTH 8
+#define GIF_FONT_WIDTH 8
#define GIF_FONT_HEIGHT 8
extern const unsigned char GifAsciiTable8x8[][GIF_FONT_WIDTH];
-extern void GifDrawText8x8(SavedImage *Image,
- const int x, const int y,
- const char *legend, const int color);
+extern void GifDrawText8x8(SavedImage *Image, const int x, const int y,
+ const char *legend, const int color);
-extern void GifDrawBox(SavedImage *Image,
- const int x, const int y,
- const int w, const int d, const int color);
+extern void GifDrawBox(SavedImage *Image, const int x, const int y, const int w,
+ const int d, const int color);
-extern void GifDrawRectangle(SavedImage *Image,
- const int x, const int y,
- const int w, const int d, const int color);
+extern void GifDrawRectangle(SavedImage *Image, const int x, const int y,
+ const int w, const int d, const int color);
-extern void GifDrawBoxedText8x8(SavedImage *Image,
- const int x, const int y,
- const char *legend,
- const int border, const int bg, const int fg);
+extern void GifDrawBoxedText8x8(SavedImage *Image, const int x, const int y,
+ const char *legend, const int border,
+ const int bg, const int fg);
#ifdef __cplusplus
}
diff --git a/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib_private.h b/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib_private.h
index 4f832676ffc..f905e0d7b48 100644
--- a/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib_private.h
+++ b/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib_private.h
@@ -33,52 +33,54 @@ SPDX-License-Identifier: MIT
#ifndef _GIF_LIB_PRIVATE_H
#define _GIF_LIB_PRIVATE_H
-#include "gif_lib.h"
#include "gif_hash.h"
+#include "gif_lib.h"
#ifndef SIZE_MAX
- #define SIZE_MAX UINTPTR_MAX
+#define SIZE_MAX UINTPTR_MAX
#endif
-#define EXTENSION_INTRODUCER 0x21
-#define DESCRIPTOR_INTRODUCER 0x2c
-#define TERMINATOR_INTRODUCER 0x3b
+#define EXTENSION_INTRODUCER 0x21
+#define DESCRIPTOR_INTRODUCER 0x2c
+#define TERMINATOR_INTRODUCER 0x3b
-#define LZ_MAX_CODE 4095 /* Biggest code possible in 12 bits. */
-#define LZ_BITS 12
+#define LZ_MAX_CODE 4095 /* Biggest code possible in 12 bits. */
+#define LZ_BITS 12
-#define FLUSH_OUTPUT 4096 /* Impossible code, to signal flush. */
-#define FIRST_CODE 4097 /* Impossible code, to signal first. */
-#define NO_SUCH_CODE 4098 /* Impossible code, to signal empty. */
+#define FLUSH_OUTPUT 4096 /* Impossible code, to signal flush. */
+#define FIRST_CODE 4097 /* Impossible code, to signal first. */
+#define NO_SUCH_CODE 4098 /* Impossible code, to signal empty. */
-#define FILE_STATE_WRITE 0x01
-#define FILE_STATE_SCREEN 0x02
-#define FILE_STATE_IMAGE 0x04
-#define FILE_STATE_READ 0x08
+#define FILE_STATE_WRITE 0x01
+#define FILE_STATE_SCREEN 0x02
+#define FILE_STATE_IMAGE 0x04
+#define FILE_STATE_READ 0x08
-#define IS_READABLE(Private) (Private->FileState & FILE_STATE_READ)
-#define IS_WRITEABLE(Private) (Private->FileState & FILE_STATE_WRITE)
+#define IS_READABLE(Private) (Private->FileState & FILE_STATE_READ)
+#define IS_WRITEABLE(Private) (Private->FileState & FILE_STATE_WRITE)
typedef struct GifFilePrivateType {
- GifWord FileState, FileHandle, /* Where all this data goes to! */
- BitsPerPixel, /* Bits per pixel (Codes uses at least this + 1). */
- ClearCode, /* The CLEAR LZ code. */
- EOFCode, /* The EOF LZ code. */
- RunningCode, /* The next code algorithm can generate. */
- RunningBits, /* The number of bits required to represent RunningCode. */
- MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits. */
- LastCode, /* The code before the current code. */
- CrntCode, /* Current algorithm code. */
- StackPtr, /* For character stack (see below). */
- CrntShiftState; /* Number of bits in CrntShiftDWord. */
- unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */
- unsigned long PixelCount; /* Number of pixels in image. */
- FILE *File; /* File as stream. */
- InputFunc Read; /* function to read gif input (TVT) */
- OutputFunc Write; /* function to write gif output (MRB) */
- GifByteType Buf[256]; /* Compressed input is buffered here. */
+ GifWord FileState, FileHandle, /* Where all this data goes to! */
+ BitsPerPixel, /* Bits per pixel (Codes uses at least this + 1). */
+ ClearCode, /* The CLEAR LZ code. */
+ EOFCode, /* The EOF LZ code. */
+ RunningCode, /* The next code algorithm can generate. */
+ RunningBits, /* The number of bits required to represent
+ RunningCode. */
+ MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits.
+ */
+ LastCode, /* The code before the current code. */
+ CrntCode, /* Current algorithm code. */
+ StackPtr, /* For character stack (see below). */
+ CrntShiftState; /* Number of bits in CrntShiftDWord. */
+ unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */
+ unsigned long PixelCount; /* Number of pixels in image. */
+ FILE *File; /* File as stream. */
+ InputFunc Read; /* function to read gif input (TVT) */
+ OutputFunc Write; /* function to write gif output (MRB) */
+ GifByteType Buf[256]; /* Compressed input is buffered here. */
GifByteType Stack[LZ_MAX_CODE]; /* Decoded pixels are stacked here. */
- GifByteType Suffix[LZ_MAX_CODE + 1]; /* So we can trace the codes. */
+ GifByteType Suffix[LZ_MAX_CODE + 1]; /* So we can trace the codes. */
GifPrefixType Prefix[LZ_MAX_CODE + 1];
GifHashTableType *HashTable;
bool gif89;
diff --git a/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c b/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c
index 75b74b4fba0..5aef3044558 100644
--- a/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c
+++ b/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c
@@ -30,59 +30,59 @@ SPDX-License-Identifier: MIT
****************************************************************************/
-#include
#include
+#include
#include
#include "gif_lib.h"
#include "gif_lib_private.h"
-#define MAX(x, y) (((x) > (y)) ? (x) : (y))
+#define MAX(x, y) (((x) > (y)) ? (x) : (y))
/******************************************************************************
Miscellaneous utility functions
******************************************************************************/
/* return smallest bitfield size n will fit in */
-int
-GifBitSize(int n)
-{
+int GifBitSize(int n) {
register int i;
- for (i = 1; i <= 8; i++)
- if ((1 << i) >= n)
+ for (i = 1; i <= 8; i++) {
+ if ((1 << i) >= n) {
break;
+ }
+ }
return (i);
}
/******************************************************************************
- Color map object functions
+ Color map object functions
******************************************************************************/
/*
* Allocate a color map of given size; initialize with contents of
* ColorMap if that pointer is non-NULL.
*/
-ColorMapObject *
-GifMakeMapObject(int ColorCount, const GifColorType *ColorMap)
-{
+ColorMapObject *GifMakeMapObject(int ColorCount, const GifColorType *ColorMap) {
ColorMapObject *Object;
/*** FIXME: Our ColorCount has to be a power of two. Is it necessary to
- * make the user know that or should we automatically round up instead? */
+ * make the user know that or should we automatically round up instead?
+ */
if (ColorCount != (1 << GifBitSize(ColorCount))) {
- return ((ColorMapObject *) NULL);
+ return ((ColorMapObject *)NULL);
}
Object = (ColorMapObject *)malloc(sizeof(ColorMapObject));
- if (Object == (ColorMapObject *) NULL) {
- return ((ColorMapObject *) NULL);
+ if (Object == (ColorMapObject *)NULL) {
+ return ((ColorMapObject *)NULL);
}
- Object->Colors = (GifColorType *)calloc(ColorCount, sizeof(GifColorType));
- if (Object->Colors == (GifColorType *) NULL) {
+ Object->Colors =
+ (GifColorType *)calloc(ColorCount, sizeof(GifColorType));
+ if (Object->Colors == (GifColorType *)NULL) {
free(Object);
- return ((ColorMapObject *) NULL);
+ return ((ColorMapObject *)NULL);
}
Object->ColorCount = ColorCount;
@@ -90,19 +90,17 @@ GifMakeMapObject(int ColorCount, const GifColorType *ColorMap)
Object->SortFlag = false;
if (ColorMap != NULL) {
- memcpy((char *)Object->Colors,
- (char *)ColorMap, ColorCount * sizeof(GifColorType));
+ memcpy((char *)Object->Colors, (char *)ColorMap,
+ ColorCount * sizeof(GifColorType));
}
return (Object);
}
/*******************************************************************************
-Free a color map object
+ Free a color map object
*******************************************************************************/
-void
-GifFreeMapObject(ColorMapObject *Object)
-{
+void GifFreeMapObject(ColorMapObject *Object) {
if (Object != NULL) {
(void)free(Object->Colors);
(void)free(Object);
@@ -110,17 +108,14 @@ GifFreeMapObject(ColorMapObject *Object)
}
#ifdef DEBUG
-void
-DumpColorMap(ColorMapObject *Object,
- FILE * fp)
-{
+void DumpColorMap(ColorMapObject *Object, FILE *fp) {
if (Object != NULL) {
int i, j, Len = Object->ColorCount;
for (i = 0; i < Len; i += 4) {
for (j = 0; j < 4 && j < Len; j++) {
- (void)fprintf(fp, "%3d: %02x %02x %02x ", i + j,
- Object->Colors[i + j].Red,
+ (void)fprintf(fp, "%3d: %02x %02x %02x ",
+ i + j, Object->Colors[i + j].Red,
Object->Colors[i + j].Green,
Object->Colors[i + j].Blue);
}
@@ -137,11 +132,9 @@ DumpColorMap(ColorMapObject *Object,
copied iff they didn't exist before. ColorTransIn2 maps the old
ColorIn2 into the ColorUnion color map table./
*******************************************************************************/
-ColorMapObject *
-GifUnionColorMap(const ColorMapObject *ColorIn1,
- const ColorMapObject *ColorIn2,
- GifPixelType ColorTransIn2[])
-{
+ColorMapObject *GifUnionColorMap(const ColorMapObject *ColorIn1,
+ const ColorMapObject *ColorIn2,
+ GifPixelType ColorTransIn2[]) {
int i, j, CrntSlot, RoundUpTo, NewGifBitSize;
ColorMapObject *ColorUnion;
@@ -152,17 +145,19 @@ GifUnionColorMap(const ColorMapObject *ColorIn1,
*/
/* Allocate table which will hold the result for sure. */
- ColorUnion = GifMakeMapObject(MAX(ColorIn1->ColorCount,
- ColorIn2->ColorCount) * 2, NULL);
+ ColorUnion = GifMakeMapObject(
+ MAX(ColorIn1->ColorCount, ColorIn2->ColorCount) * 2, NULL);
- if (ColorUnion == NULL)
+ if (ColorUnion == NULL) {
return (NULL);
+ }
/*
* Copy ColorIn1 to ColorUnion.
*/
- for (i = 0; i < ColorIn1->ColorCount; i++)
+ for (i = 0; i < ColorIn1->ColorCount; i++) {
ColorUnion->Colors[i] = ColorIn1->Colors[i];
+ }
CrntSlot = ColorIn1->ColorCount;
/*
@@ -172,22 +167,25 @@ GifUnionColorMap(const ColorMapObject *ColorIn1,
* of table 1. This is very useful if your display is limited to
* 16 colors.
*/
- while (ColorIn1->Colors[CrntSlot - 1].Red == 0
- && ColorIn1->Colors[CrntSlot - 1].Green == 0
- && ColorIn1->Colors[CrntSlot - 1].Blue == 0)
+ while (ColorIn1->Colors[CrntSlot - 1].Red == 0 &&
+ ColorIn1->Colors[CrntSlot - 1].Green == 0 &&
+ ColorIn1->Colors[CrntSlot - 1].Blue == 0) {
CrntSlot--;
+ }
/* Copy ColorIn2 to ColorUnion (use old colors if they exist): */
for (i = 0; i < ColorIn2->ColorCount && CrntSlot <= 256; i++) {
/* Let's see if this color already exists: */
- for (j = 0; j < ColorIn1->ColorCount; j++)
- if (memcmp (&ColorIn1->Colors[j], &ColorIn2->Colors[i],
- sizeof(GifColorType)) == 0)
+ for (j = 0; j < ColorIn1->ColorCount; j++) {
+ if (memcmp(&ColorIn1->Colors[j], &ColorIn2->Colors[i],
+ sizeof(GifColorType)) == 0) {
break;
+ }
+ }
- if (j < ColorIn1->ColorCount)
- ColorTransIn2[i] = j; /* color exists in Color1 */
- else {
+ if (j < ColorIn1->ColorCount) {
+ ColorTransIn2[i] = j; /* color exists in Color1 */
+ } else {
/* Color is new - copy it to a new slot: */
ColorUnion->Colors[CrntSlot] = ColorIn2->Colors[i];
ColorTransIn2[i] = CrntSlot++;
@@ -196,7 +194,7 @@ GifUnionColorMap(const ColorMapObject *ColorIn1,
if (CrntSlot > 256) {
GifFreeMapObject(ColorUnion);
- return ((ColorMapObject *) NULL);
+ return ((ColorMapObject *)NULL);
}
NewGifBitSize = GifBitSize(CrntSlot);
@@ -210,16 +208,17 @@ GifUnionColorMap(const ColorMapObject *ColorIn1,
* We know these slots exist because of the way ColorUnion's
* start dimension was computed.
*/
- for (j = CrntSlot; j < RoundUpTo; j++)
+ for (j = CrntSlot; j < RoundUpTo; j++) {
Map[j].Red = Map[j].Green = Map[j].Blue = 0;
+ }
/* perhaps we can shrink the map? */
if (RoundUpTo < ColorUnion->ColorCount) {
- GifColorType *new_map = (GifColorType *)reallocarray(Map,
- RoundUpTo, sizeof(GifColorType));
- if( new_map == NULL ) {
+ GifColorType *new_map = (GifColorType *)reallocarray(
+ Map, RoundUpTo, sizeof(GifColorType));
+ if (new_map == NULL) {
GifFreeMapObject(ColorUnion);
- return ((ColorMapObject *) NULL);
+ return ((ColorMapObject *)NULL);
}
ColorUnion->Colors = new_map;
}
@@ -234,49 +233,49 @@ GifUnionColorMap(const ColorMapObject *ColorIn1,
/*******************************************************************************
Apply a given color translation to the raster bits of an image
*******************************************************************************/
-void
-GifApplyTranslation(SavedImage *Image, GifPixelType Translation[])
-{
+void GifApplyTranslation(SavedImage *Image, const GifPixelType Translation[]) {
register int i;
- register int RasterSize = Image->ImageDesc.Height * Image->ImageDesc.Width;
+ register int RasterSize =
+ Image->ImageDesc.Height * Image->ImageDesc.Width;
- for (i = 0; i < RasterSize; i++)
+ for (i = 0; i < RasterSize; i++) {
Image->RasterBits[i] = Translation[Image->RasterBits[i]];
+ }
}
/******************************************************************************
Extension record functions
******************************************************************************/
-int
-GifAddExtensionBlock(int *ExtensionBlockCount,
- ExtensionBlock **ExtensionBlocks,
- int Function,
- unsigned int Len,
- unsigned char ExtData[])
-{
+int GifAddExtensionBlock(int *ExtensionBlockCount,
+ ExtensionBlock **ExtensionBlocks, int Function,
+ unsigned int Len, unsigned char ExtData[]) {
ExtensionBlock *ep;
- if (*ExtensionBlocks == NULL)
- *ExtensionBlocks=(ExtensionBlock *)malloc(sizeof(ExtensionBlock));
- else {
- ExtensionBlock* ep_new = (ExtensionBlock *)reallocarray
- (*ExtensionBlocks, (*ExtensionBlockCount + 1),
- sizeof(ExtensionBlock));
- if( ep_new == NULL )
+ if (*ExtensionBlocks == NULL) {
+ *ExtensionBlocks =
+ (ExtensionBlock *)malloc(sizeof(ExtensionBlock));
+ } else {
+ ExtensionBlock *ep_new = (ExtensionBlock *)reallocarray(
+ *ExtensionBlocks, (*ExtensionBlockCount + 1),
+ sizeof(ExtensionBlock));
+ if (ep_new == NULL) {
return (GIF_ERROR);
+ }
*ExtensionBlocks = ep_new;
}
- if (*ExtensionBlocks == NULL)
+ if (*ExtensionBlocks == NULL) {
return (GIF_ERROR);
+ }
ep = &(*ExtensionBlocks)[(*ExtensionBlockCount)++];
ep->Function = Function;
- ep->ByteCount=Len;
+ ep->ByteCount = Len;
ep->Bytes = (GifByteType *)malloc(ep->ByteCount);
- if (ep->Bytes == NULL)
+ if (ep->Bytes == NULL) {
return (GIF_ERROR);
+ }
if (ExtData != NULL) {
memcpy(ep->Bytes, ExtData, Len);
@@ -285,38 +284,36 @@ GifAddExtensionBlock(int *ExtensionBlockCount,
return (GIF_OK);
}
-void
-GifFreeExtensions(int *ExtensionBlockCount,
- ExtensionBlock **ExtensionBlocks)
-{
+void GifFreeExtensions(int *ExtensionBlockCount,
+ ExtensionBlock **ExtensionBlocks) {
ExtensionBlock *ep;
- if (*ExtensionBlocks == NULL)
+ if (*ExtensionBlocks == NULL) {
return;
+ }
for (ep = *ExtensionBlocks;
- ep < (*ExtensionBlocks + *ExtensionBlockCount);
- ep++)
+ ep < (*ExtensionBlocks + *ExtensionBlockCount); ep++) {
(void)free((char *)ep->Bytes);
+ }
(void)free((char *)*ExtensionBlocks);
*ExtensionBlocks = NULL;
*ExtensionBlockCount = 0;
}
/******************************************************************************
- Image block allocation functions
+ Image block allocation functions
******************************************************************************/
/* Private Function:
* Frees the last image in the GifFile->SavedImages array
*/
-void
-FreeLastSavedImage(GifFileType *GifFile)
-{
+void FreeLastSavedImage(GifFileType *GifFile) {
SavedImage *sp;
- if ((GifFile == NULL) || (GifFile->SavedImages == NULL))
+ if ((GifFile == NULL) || (GifFile->SavedImages == NULL)) {
return;
+ }
/* Remove one SavedImage from the GifFile */
GifFile->ImageCount--;
@@ -329,54 +326,58 @@ FreeLastSavedImage(GifFileType *GifFile)
}
/* Deallocate the image data */
- if (sp->RasterBits != NULL)
+ if (sp->RasterBits != NULL) {
free((char *)sp->RasterBits);
+ }
/* Deallocate any extensions */
GifFreeExtensions(&sp->ExtensionBlockCount, &sp->ExtensionBlocks);
/*** FIXME: We could realloc the GifFile->SavedImages structure but is
* there a point to it? Saves some memory but we'd have to do it every
- * time. If this is used in GifFreeSavedImages then it would be inefficient
- * (The whole array is going to be deallocated.) If we just use it when
- * we want to free the last Image it's convenient to do it here.
+ * time. If this is used in GifFreeSavedImages then it would be
+ * inefficient (The whole array is going to be deallocated.) If we just
+ * use it when we want to free the last Image it's convenient to do it
+ * here.
*/
}
/*
* Append an image block to the SavedImages array
*/
-SavedImage *
-GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom)
-{
- if (GifFile->SavedImages == NULL)
+SavedImage *GifMakeSavedImage(GifFileType *GifFile,
+ const SavedImage *CopyFrom) {
+ // cppcheck-suppress ctunullpointer
+ if (GifFile->SavedImages == NULL) {
GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage));
- else {
- SavedImage* newSavedImages = (SavedImage *)reallocarray(GifFile->SavedImages,
- (GifFile->ImageCount + 1), sizeof(SavedImage));
- if( newSavedImages == NULL)
+ } else {
+ SavedImage *newSavedImages = (SavedImage *)reallocarray(
+ GifFile->SavedImages, (GifFile->ImageCount + 1),
+ sizeof(SavedImage));
+ if (newSavedImages == NULL) {
return ((SavedImage *)NULL);
+ }
GifFile->SavedImages = newSavedImages;
}
- if (GifFile->SavedImages == NULL)
+ if (GifFile->SavedImages == NULL) {
return ((SavedImage *)NULL);
- else {
+ } else {
SavedImage *sp = &GifFile->SavedImages[GifFile->ImageCount++];
if (CopyFrom != NULL) {
memcpy((char *)sp, CopyFrom, sizeof(SavedImage));
/*
- * Make our own allocated copies of the heap fields in the
- * copied record. This guards against potential aliasing
- * problems.
+ * Make our own allocated copies of the heap fields in
+ * the copied record. This guards against potential
+ * aliasing problems.
*/
/* first, the local color map */
if (CopyFrom->ImageDesc.ColorMap != NULL) {
sp->ImageDesc.ColorMap = GifMakeMapObject(
- CopyFrom->ImageDesc.ColorMap->ColorCount,
- CopyFrom->ImageDesc.ColorMap->Colors);
+ CopyFrom->ImageDesc.ColorMap->ColorCount,
+ CopyFrom->ImageDesc.ColorMap->Colors);
if (sp->ImageDesc.ColorMap == NULL) {
FreeLastSavedImage(GifFile);
return (SavedImage *)(NULL);
@@ -384,32 +385,36 @@ GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom)
}
/* next, the raster */
- sp->RasterBits = (unsigned char *)reallocarray(NULL,
- (CopyFrom->ImageDesc.Height *
- CopyFrom->ImageDesc.Width),
- sizeof(GifPixelType));
+ sp->RasterBits = (unsigned char *)reallocarray(
+ NULL,
+ (CopyFrom->ImageDesc.Height *
+ CopyFrom->ImageDesc.Width),
+ sizeof(GifPixelType));
if (sp->RasterBits == NULL) {
FreeLastSavedImage(GifFile);
return (SavedImage *)(NULL);
}
memcpy(sp->RasterBits, CopyFrom->RasterBits,
- sizeof(GifPixelType) * CopyFrom->ImageDesc.Height *
- CopyFrom->ImageDesc.Width);
+ sizeof(GifPixelType) *
+ CopyFrom->ImageDesc.Height *
+ CopyFrom->ImageDesc.Width);
/* finally, the extension blocks */
if (CopyFrom->ExtensionBlocks != NULL) {
- sp->ExtensionBlocks = (ExtensionBlock *)reallocarray(NULL,
- CopyFrom->ExtensionBlockCount,
- sizeof(ExtensionBlock));
+ sp->ExtensionBlocks =
+ (ExtensionBlock *)reallocarray(
+ NULL, CopyFrom->ExtensionBlockCount,
+ sizeof(ExtensionBlock));
if (sp->ExtensionBlocks == NULL) {
FreeLastSavedImage(GifFile);
return (SavedImage *)(NULL);
}
- memcpy(sp->ExtensionBlocks, CopyFrom->ExtensionBlocks,
- sizeof(ExtensionBlock) * CopyFrom->ExtensionBlockCount);
+ memcpy(sp->ExtensionBlocks,
+ CopyFrom->ExtensionBlocks,
+ sizeof(ExtensionBlock) *
+ CopyFrom->ExtensionBlockCount);
}
- }
- else {
+ } else {
memset((char *)sp, '\0', sizeof(SavedImage));
}
@@ -417,9 +422,7 @@ GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom)
}
}
-void
-GifFreeSavedImages(GifFileType *GifFile)
-{
+void GifFreeSavedImages(GifFileType *GifFile) {
SavedImage *sp;
if ((GifFile == NULL) || (GifFile->SavedImages == NULL)) {
@@ -432,10 +435,12 @@ GifFreeSavedImages(GifFileType *GifFile)
sp->ImageDesc.ColorMap = NULL;
}
- if (sp->RasterBits != NULL)
+ if (sp->RasterBits != NULL) {
free((char *)sp->RasterBits);
+ }
- GifFreeExtensions(&sp->ExtensionBlockCount, &sp->ExtensionBlocks);
+ GifFreeExtensions(&sp->ExtensionBlockCount,
+ &sp->ExtensionBlocks);
}
free((char *)GifFile->SavedImages);
GifFile->SavedImages = NULL;
diff --git a/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c b/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c
index 452df69d7cd..7420af674c5 100644
--- a/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c
+++ b/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c
@@ -28,24 +28,22 @@
* SPDX-License-Identifier: MIT
*/
-#include
#include
#include
#include
+#include
#ifndef SIZE_MAX
- #define SIZE_MAX UINTPTR_MAX
+#define SIZE_MAX UINTPTR_MAX
#endif
/*
* This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
* if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW
*/
-#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
+#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
-void *
-openbsd_reallocarray(void *optr, size_t nmemb, size_t size)
-{
+void *openbsd_reallocarray(void *optr, size_t nmemb, size_t size) {
if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
nmemb > 0 && SIZE_MAX / nmemb < size) {
errno = ENOMEM;
@@ -93,7 +91,8 @@ openbsd_reallocarray(void *optr, size_t nmemb, size_t size)
* fuzzing on one platform may not detect zero-size allocation
* problems on other platforms.
*/
- if (size == 0 || nmemb == 0)
+ if (size == 0 || nmemb == 0) {
return NULL;
+ }
return realloc(optr, size * nmemb);
}
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES b/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES
index 2d8c585c0e7..441b57ecf1a 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES
@@ -6129,6 +6129,73 @@ Version 1.6.40 [June 21, 2023]
Updated the configurations and the scripts for continuous integration.
Cleaned up the code, the build scripts, and the documentation.
+Version 1.6.41 [January 24, 2024]
+ Added SIMD-optimized code for the LoongArch LSX hardware.
+ (Contributed by GuXiWei, JinBo and ZhangLixia)
+ Fixed the run-time discovery of MIPS MSA hardware.
+ (Contributed by Sui Jingfeng)
+ Fixed an off-by-one error in the function png_do_check_palette_indexes(),
+ which failed to recognize errors that might have existed in the first
+ column of a broken palette-encoded image. This was a benign regression
+ accidentally introduced in libpng-1.6.33. No pixel was harmed.
+ (Contributed by Adam Richter; reviewed by John Bowler)
+ Fixed, improved and modernized the contrib/pngminus programs, i.e.,
+ png2pnm.c and pnm2png.c
+ Removed old and peculiar portability hacks that were meant to silence
+ warnings issued by gcc version 7.1 alone.
+ (Contributed by John Bowler)
+ Fixed and modernized the CMake file, and raised the minimum required
+ CMake version from 3.1 to 3.6.
+ (Contributed by Clinton Ingram, Timothy Lyanguzov, Tyler Kropp, et al.)
+ Allowed the configure script to disable the building of auxiliary tools
+ and tests, thus catching up with the CMake file.
+ (Contributed by Carlo Bramini)
+ Fixed a build issue on Mac.
+ (Contributed by Zixu Wang)
+ Moved the Autoconf macro files to scripts/autoconf.
+ Moved the CMake files (except for the main CMakeLists.txt) to
+ scripts/cmake and moved the list of their contributing authors to
+ scripts/cmake/AUTHORS.md
+ Updated the CI configurations and scripts.
+ Relicensed the CI scripts to the MIT License.
+ Improved the test coverage.
+ (Contributed by John Bowler)
+
+Version 1.6.42 [January 29, 2024]
+ Fixed the implementation of the macro function png_check_sig().
+ This was an API regression, introduced in libpng-1.6.41.
+ (Reported by Matthieu Darbois)
+ Fixed and updated the libpng manual.
+
+Version 1.6.43 [February 23, 2024]
+ Fixed the row width check in png_check_IHDR().
+ This corrected a bug that was specific to the 16-bit platforms,
+ and removed a spurious compiler warning from the 64-bit builds.
+ (Reported by Jacek Caban; fixed by John Bowler)
+ Added eXIf chunk support to the push-mode reader in pngpread.c.
+ (Contributed by Chris Blume)
+ Added contrib/pngexif for the benefit of the users who would like
+ to inspect the content of eXIf chunks.
+ Added contrib/conftest/basic.dfa, a basic build-time configuration.
+ (Contributed by John Bowler)
+ Fixed a preprocessor condition in pngread.c that broke build-time
+ configurations like contrib/conftest/pngcp.dfa.
+ (Contributed by John Bowler)
+ Added CMake build support for LoongArch LSX.
+ (Contributed by GuXiWei)
+ Fixed a CMake build error that occurred under a peculiar state of the
+ dependency tree. This was a regression introduced in libpng-1.6.41.
+ (Contributed by Dan Rosser)
+ Marked the installed libpng headers as system headers in CMake.
+ (Contributed by Benjamin Buch)
+ Updated the build support for RISCOS.
+ (Contributed by Cameron Cawley)
+ Updated the makefiles to allow cross-platform builds to initialize
+ conventional make variables like AR and ARFLAGS.
+ Added various improvements to the CI scripts in areas like version
+ consistency verification and text linting.
+ Added version consistency verification to pngtest.c also.
+
Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
Subscription is required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE b/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE
index 086d1c2fda6..25f298f0fcf 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE
@@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
PNG Reference Library License version 2
---------------------------------------
- * Copyright (c) 1995-2023 The PNG Reference Library Authors.
- * Copyright (c) 2018-2023 Cosmin Truta.
+ * Copyright (c) 1995-2024 The PNG Reference Library Authors.
+ * Copyright (c) 2018-2024 Cosmin Truta.
* Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
* Copyright (c) 1996-1997 Andreas Dilger.
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/README b/src/java.desktop/share/native/libsplashscreen/libpng/README
index dedd2c1639e..a6ca3ae9f94 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/README
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/README
@@ -1,4 +1,4 @@
-README for libpng version 1.6.40
+README for libpng version 1.6.43
================================
See the note about version numbers near the top of `png.h`.
@@ -142,10 +142,11 @@ Files included in this distribution
pngwrite.c => High-level write functions
pngwtran.c => Write data transformations
pngwutil.c => Write utility functions
- arm/ => Optimized code for the ARM platform
- intel/ => Optimized code for the INTEL-SSE2 platform
- mips/ => Optimized code for the MIPS platform
- powerpc/ => Optimized code for the PowerPC platform
+ arm/ => Optimized code for ARM Neon
+ intel/ => Optimized code for INTEL SSE2
+ loongarch/ => Optimized code for LoongArch LSX
+ mips/ => Optimized code for MIPS MSA and MIPS MMI
+ powerpc/ => Optimized code for PowerPC VSX
ci/ => Scripts for continuous integration
contrib/ => External contributions
arm-neon/ => Optimized code for the ARM-NEON platform
@@ -158,6 +159,7 @@ Files included in this distribution
libtests/ => Test programs
oss-fuzz/ => Files used by the OSS-Fuzz project for fuzz-testing
libpng
+ pngexif/ => Program to inspect the EXIF information in PNG files
pngminim/ => Minimal decoder, encoder, and progressive decoder
programs demonstrating the use of pngusr.dfa
pngminus/ => Simple pnm2png and png2pnm programs
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/UPDATING.txt b/src/java.desktop/share/native/libsplashscreen/libpng/UPDATING.txt
index 93c8f5bb703..88200db5d73 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/UPDATING.txt
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/UPDATING.txt
@@ -37,18 +37,21 @@ and instead just tweak the existing one.
First cd into the libpng folder and run the following script.
+ shopt -s nullglob
for f in *.c *.h;
- do
- # replace tabs with spaces
- expand ${f} > ${f}.tmp;
- mv ${f}.tmp $f;
-
- # fix line endings to LF
- sed -i -e 's/\r$//g' ${f};
-
- # remove trailing spaces
- sed -i -e 's/[ ]* $//g' ${f};
- done
+ do
+ # replace tabs with spaces
+ expand ${f} > ${f}.tmp
+ mv ${f}.tmp $f
+
+ # fix line endings to LF
+ sed -e 's/\r$//g' ${f} > ${f}.tmp
+ mv ${f}.tmp $f
+
+ # remove trailing spaces
+ sed -e 's/[ ]* $//g' ${f} > ${f}.tmp
+ mv ${f}.tmp $f
+ done
6) As with all native code, run it through the official build systems, in case
the updated code trigger any fatal warnings with the official compilers.
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/png.c b/src/java.desktop/share/native/libsplashscreen/libpng/png.c
index 91a92e5f718..232dff876c7 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/png.c
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/png.c
@@ -29,7 +29,7 @@
* However, the following notice accompanied the original version of this
* file and, per its terms, should not be removed:
*
- * Copyright (c) 2018-2023 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -42,27 +42,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_40 Your_png_h_is_not_version_1_6_40;
-
-#ifdef __GNUC__
-/* The version tests may need to be added to, but the problem warning has
- * consistently been fixed in GCC versions which obtain wide-spread release.
- * The problem is that many versions of GCC rearrange comparison expressions in
- * the optimizer in such a way that the results of the comparison will change
- * if signed integer overflow occurs. Such comparisons are not permitted in
- * ANSI C90, however GCC isn't clever enough to work out that that do not occur
- * below in png_ascii_from_fp and png_muldiv, so it produces a warning with
- * -Wextra. Unfortunately this is highly dependent on the optimizer and the
- * machine architecture so the warning comes and goes unpredictably and is
- * impossible to "fix", even were that a good idea.
- */
-#if __GNUC__ == 7 && __GNUC_MINOR__ == 1
-#define GCC_STRICT_OVERFLOW 1
-#endif /* GNU 7.1.x */
-#endif /* GNU */
-#ifndef GCC_STRICT_OVERFLOW
-#define GCC_STRICT_OVERFLOW 0
-#endif
+typedef png_libpng_version_1_6_43 Your_png_h_is_not_version_1_6_43;
/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
@@ -101,21 +81,21 @@ png_set_sig_bytes(png_structrp png_ptr, int num_bytes)
int PNGAPI
png_sig_cmp(png_const_bytep sig, size_t start, size_t num_to_check)
{
- png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
+ static const png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
if (num_to_check > 8)
num_to_check = 8;
else if (num_to_check < 1)
- return (-1);
+ return -1;
if (start > 7)
- return (-1);
+ return -1;
if (start + num_to_check > 8)
num_to_check = 8 - start;
- return ((int)(memcmp(&sig[start], &png_signature[start], num_to_check)));
+ return memcmp(&sig[start], &png_signature[start], num_to_check);
}
#endif /* READ */
@@ -475,7 +455,6 @@ png_info_init_3,(png_infopp ptr_ptr, size_t png_info_struct_size),
memset(info_ptr, 0, (sizeof *info_ptr));
}
-/* The following API is not called internally */
void PNGAPI
png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr,
int freer, png_uint_32 mask)
@@ -714,9 +693,9 @@ png_voidp PNGAPI
png_get_io_ptr(png_const_structrp png_ptr)
{
if (png_ptr == NULL)
- return (NULL);
+ return NULL;
- return (png_ptr->io_ptr);
+ return png_ptr->io_ptr;
}
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
@@ -780,7 +759,7 @@ png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
{
size_t pos = 0;
- char number_buf[5]; /* enough for a four-digit year */
+ char number_buf[5] = {0, 0, 0, 0, 0}; /* enough for a four-digit year */
# define APPEND_STRING(string) pos = png_safecat(out, 29, pos, (string))
# define APPEND_NUMBER(format, value)\
@@ -843,8 +822,8 @@ png_get_copyright(png_const_structrp png_ptr)
return PNG_STRING_COPYRIGHT
#else
return PNG_STRING_NEWLINE \
- "libpng version 1.6.40" PNG_STRING_NEWLINE \
- "Copyright (c) 2018-2023 Cosmin Truta" PNG_STRING_NEWLINE \
+ "libpng version 1.6.43" PNG_STRING_NEWLINE \
+ "Copyright (c) 2018-2024 Cosmin Truta" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
@@ -1005,7 +984,7 @@ png_reset_zstream(png_structrp png_ptr)
return Z_STREAM_ERROR;
/* WARNING: this resets the window bits to the maximum! */
- return (inflateReset(&png_ptr->zstream));
+ return inflateReset(&png_ptr->zstream);
}
#endif /* READ */
@@ -1014,7 +993,7 @@ png_uint_32 PNGAPI
png_access_version_number(void)
{
/* Version of *.c files used when building libpng */
- return((png_uint_32)PNG_LIBPNG_VER);
+ return (png_uint_32)PNG_LIBPNG_VER;
}
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
@@ -1870,14 +1849,14 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
}
# ifdef PNG_WARNINGS_SUPPORTED
else
- {
- char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114 */
+ {
+ char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114 */
- pos = png_safecat(message, (sizeof message), pos,
- png_format_number(number, number+(sizeof number),
- PNG_NUMBER_FORMAT_x, value));
- pos = png_safecat(message, (sizeof message), pos, "h: "); /* +2 = 116 */
- }
+ pos = png_safecat(message, (sizeof message), pos,
+ png_format_number(number, number+(sizeof number),
+ PNG_NUMBER_FORMAT_x, value));
+ pos = png_safecat(message, (sizeof message), pos, "h: "); /* +2 = 116 */
+ }
# endif
/* The 'reason' is an arbitrary message, allow +79 maximum 195 */
pos = png_safecat(message, (sizeof message), pos, reason);
@@ -2560,17 +2539,6 @@ png_colorspace_set_rgb_coefficients(png_structrp png_ptr)
#endif /* COLORSPACE */
-#ifdef __GNUC__
-/* This exists solely to work round a warning from GNU C. */
-static int /* PRIVATE */
-png_gt(size_t a, size_t b)
-{
- return a > b;
-}
-#else
-# define png_gt(a,b) ((a) > (b))
-#endif
-
void /* PRIVATE */
png_check_IHDR(png_const_structrp png_ptr,
png_uint_32 width, png_uint_32 height, int bit_depth,
@@ -2592,8 +2560,16 @@ png_check_IHDR(png_const_structrp png_ptr,
error = 1;
}
- if (png_gt(((width + 7) & (~7U)),
- ((PNG_SIZE_MAX
+ /* The bit mask on the first line below must be at least as big as a
+ * png_uint_32. "~7U" is not adequate on 16-bit systems because it will
+ * be an unsigned 16-bit value. Casting to (png_alloc_size_t) makes the
+ * type of the result at least as bit (in bits) as the RHS of the > operator
+ * which also avoids a common warning on 64-bit systems that the comparison
+ * of (png_uint_32) against the constant value on the RHS will always be
+ * false.
+ */
+ if (((width + 7) & ~(png_alloc_size_t)7) >
+ (((PNG_SIZE_MAX
- 48 /* big_row_buf hack */
- 1) /* filter byte */
/ 8) /* 8-byte RGBA pixels */
@@ -2919,14 +2895,6 @@ png_pow10(int power)
/* Function to format a floating point value in ASCII with a given
* precision.
*/
-#if GCC_STRICT_OVERFLOW
-#pragma GCC diagnostic push
-/* The problem arises below with exp_b10, which can never overflow because it
- * comes, originally, from frexp and is therefore limited to a range which is
- * typically +/-710 (log2(DBL_MAX)/log2(DBL_MIN)).
- */
-#pragma GCC diagnostic warning "-Wstrict-overflow=2"
-#endif /* GCC_STRICT_OVERFLOW */
void /* PRIVATE */
png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, size_t size,
double fp, unsigned int precision)
@@ -3248,10 +3216,6 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, size_t size,
/* Here on buffer too small. */
png_error(png_ptr, "ASCII conversion buffer too small");
}
-#if GCC_STRICT_OVERFLOW
-#pragma GCC diagnostic pop
-#endif /* GCC_STRICT_OVERFLOW */
-
# endif /* FLOATING_POINT */
# ifdef PNG_FIXED_POINT_SUPPORTED
@@ -3279,7 +3243,7 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
if (num <= 0x80000000) /* else overflowed */
{
unsigned int ndigits = 0, first = 16 /* flag value */;
- char digits[10];
+ char digits[10] = {0};
while (num)
{
@@ -3364,15 +3328,6 @@ png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
* the nearest .00001). Overflow and divide by zero are signalled in
* the result, a boolean - true on success, false on overflow.
*/
-#if GCC_STRICT_OVERFLOW /* from above */
-/* It is not obvious which comparison below gets optimized in such a way that
- * signed overflow would change the result; looking through the code does not
- * reveal any tests which have the form GCC complains about, so presumably the
- * optimizer is moving an add or subtract into the 'if' somewhere.
- */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic warning "-Wstrict-overflow=2"
-#endif /* GCC_STRICT_OVERFLOW */
int
png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
png_int_32 divisor)
@@ -3487,9 +3442,6 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
return 0;
}
-#if GCC_STRICT_OVERFLOW
-#pragma GCC diagnostic pop
-#endif /* GCC_STRICT_OVERFLOW */
#endif /* READ_GAMMA || INCH_CONVERSIONS */
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/png.h b/src/java.desktop/share/native/libsplashscreen/libpng/png.h
index 578841c9580..9f61a773c1d 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/png.h
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/png.h
@@ -29,9 +29,9 @@
* However, the following notice accompanied the original version of this
* file and, per its terms, should not be removed:
*
- * libpng version 1.6.40
+ * libpng version 1.6.43
*
- * Copyright (c) 2018-2023 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -43,7 +43,7 @@
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.6.35, July 2018:
* Glenn Randers-Pehrson
- * libpng versions 1.6.36, December 2018, through 1.6.40, June 2023:
+ * libpng versions 1.6.36, December 2018, through 1.6.43, February 2024:
* Cosmin Truta
* See also "Contributing Authors", below.
*/
@@ -55,8 +55,8 @@
* PNG Reference Library License version 2
* ---------------------------------------
*
- * * Copyright (c) 1995-2023 The PNG Reference Library Authors.
- * * Copyright (c) 2018-2023 Cosmin Truta.
+ * * Copyright (c) 1995-2024 The PNG Reference Library Authors.
+ * * Copyright (c) 2018-2024 Cosmin Truta.
* * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
* * Copyright (c) 1996-1997 Andreas Dilger.
* * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -267,7 +267,7 @@
* ...
* 1.5.30 15 10530 15.so.15.30[.0]
* ...
- * 1.6.40 16 10640 16.so.16.40[.0]
+ * 1.6.43 16 10643 16.so.16.43[.0]
*
* Henceforth the source version will match the shared-library major and
* minor numbers; the shared-library major version number will be used for
@@ -283,9 +283,6 @@
* to the info_ptr or png_ptr members through png.h, and the compiled
* application is loaded with a different version of the library.
*
- * DLLNUM will change each time there are forward or backward changes
- * in binary compatibility (e.g., when a new feature is added).
- *
* See libpng.txt or libpng.3 for more information. The PNG specification
* is available as a W3C Recommendation and as an ISO/IEC Standard; see
*
@@ -306,19 +303,21 @@
*/
/* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.6.40"
-#define PNG_HEADER_VERSION_STRING " libpng version 1.6.40 - June 21, 2023\n"
+#define PNG_LIBPNG_VER_STRING "1.6.43"
+#define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n"
-#define PNG_LIBPNG_VER_SONUM 16
-#define PNG_LIBPNG_VER_DLLNUM 16
+/* The versions of shared library builds should stay in sync, going forward */
+#define PNG_LIBPNG_VER_SHAREDLIB 16
+#define PNG_LIBPNG_VER_SONUM PNG_LIBPNG_VER_SHAREDLIB /* [Deprecated] */
+#define PNG_LIBPNG_VER_DLLNUM PNG_LIBPNG_VER_SHAREDLIB /* [Deprecated] */
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 6
-#define PNG_LIBPNG_VER_RELEASE 40
+#define PNG_LIBPNG_VER_RELEASE 43
/* This should be zero for a public release, or non-zero for a
- * development version. [Deprecated]
+ * development version.
*/
#define PNG_LIBPNG_VER_BUILD 0
@@ -346,7 +345,7 @@
* From version 1.0.1 it is:
* XXYYZZ, where XX=major, YY=minor, ZZ=release
*/
-#define PNG_LIBPNG_VER 10640 /* 1.6.40 */
+#define PNG_LIBPNG_VER 10643 /* 1.6.43 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@@ -456,7 +455,7 @@ extern "C" {
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
-typedef char* png_libpng_version_1_6_40;
+typedef char* png_libpng_version_1_6_43;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
*
@@ -877,7 +876,7 @@ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);
#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */
/* Added to libpng-1.5.4 */
#define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */
-#if INT_MAX >= 0x8000 /* else this might break */
+#if ~0U > 0xffffU /* or else this might break on a 16-bit machine */
#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */
#endif
@@ -936,15 +935,15 @@ PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes));
/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
* PNG file. Returns zero if the supplied bytes match the 8-byte PNG
* signature, and non-zero otherwise. Having num_to_check == 0 or
- * start > 7 will always fail (ie return non-zero).
+ * start > 7 will always fail (i.e. return non-zero).
*/
PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, size_t start,
size_t num_to_check));
/* Simple signature checking function. This is the same as calling
- * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
+ * png_check_sig(sig, n) := (png_sig_cmp(sig, 0, n) == 0).
*/
-#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n))
+#define png_check_sig(sig, n) (png_sig_cmp((sig), 0, (n)) == 0) /* DEPRECATED */
/* Allocate and initialize png_ptr struct for reading, and any other memory. */
PNG_EXPORTA(4, png_structp, png_create_read_struct,
@@ -1758,12 +1757,9 @@ PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr));
PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,
png_inforp info_ptr, png_uint_32 free_me, int num));
-/* Reassign responsibility for freeing existing data, whether allocated
+/* Reassign the responsibility for freeing existing data, whether allocated
* by libpng or by the application; this works on the png_info structure passed
- * in, it does not change the state for other png_info structures.
- *
- * It is unlikely that this function works correctly as of 1.6.0 and using it
- * may result either in memory leaks or double free of allocated data.
+ * in, without changing the state for other png_info structures.
*/
PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
png_inforp info_ptr, int freer, png_uint_32 mask));
@@ -3235,11 +3231,18 @@ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
#ifdef PNG_MIPS_MSA_API_SUPPORTED
# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */
#endif
-#define PNG_IGNORE_ADLER32 8
+#ifdef PNG_DISABLE_ADLER32_CHECK_SUPPORTED
+# define PNG_IGNORE_ADLER32 8 /* SOFTWARE: disable Adler32 check on IDAT */
+#endif
#ifdef PNG_POWERPC_VSX_API_SUPPORTED
-# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions supported */
+# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions
+ * supported */
#endif
-#define PNG_OPTION_NEXT 12 /* Next option - numbers must be even */
+#ifdef PNG_MIPS_MMI_API_SUPPORTED
+# define PNG_MIPS_MMI 12 /* HARDWARE: MIPS MMI SIMD instructions supported */
+#endif
+
+#define PNG_OPTION_NEXT 14 /* Next option - numbers must be even */
/* Return values: NOTE: there are four values and 'off' is *not* zero */
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h b/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h
index 41cbc91d398..b3b441b1122 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h
@@ -29,9 +29,9 @@
* However, the following notice accompanied the original version of this
* file and, per its terms, should not be removed:
*
- * libpng version 1.6.40
+ * libpng version 1.6.43
*
- * Copyright (c) 2018-2022 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngerror.c b/src/java.desktop/share/native/libsplashscreen/libpng/pngerror.c
index 623735f06f1..ea8dd172197 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/pngerror.c
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngerror.c
@@ -29,7 +29,7 @@
* However, the following notice accompanied the original version of this
* file and, per its terms, should not be removed:
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -283,7 +283,7 @@ void
png_warning_parameter_unsigned(png_warning_parameters p, int number, int format,
png_alloc_size_t value)
{
- char buffer[PNG_NUMBER_BUFFER_SIZE];
+ char buffer[PNG_NUMBER_BUFFER_SIZE] = {0};
png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value));
}
@@ -293,7 +293,7 @@ png_warning_parameter_signed(png_warning_parameters p, int number, int format,
{
png_alloc_size_t u;
png_charp str;
- char buffer[PNG_NUMBER_BUFFER_SIZE];
+ char buffer[PNG_NUMBER_BUFFER_SIZE] = {0};
/* Avoid overflow by doing the negate in a png_alloc_size_t: */
u = (png_alloc_size_t)value;
@@ -886,7 +886,7 @@ png_get_error_ptr(png_const_structrp png_ptr)
if (png_ptr == NULL)
return NULL;
- return ((png_voidp)png_ptr->error_ptr);
+ return (png_voidp)png_ptr->error_ptr;
}
@@ -961,31 +961,25 @@ png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
#endif
int /* PRIVATE */
-png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)
+png_safe_execute(png_imagep image, int (*function)(png_voidp), png_voidp arg)
{
- volatile png_imagep image = image_in;
- volatile int result;
- volatile png_voidp saved_error_buf;
+ png_voidp saved_error_buf = image->opaque->error_buf;
jmp_buf safe_jmpbuf;
+ int result;
- /* Safely execute function(arg) with png_error returning to this function. */
- saved_error_buf = image->opaque->error_buf;
- result = setjmp(safe_jmpbuf) == 0;
-
- if (result != 0)
+ /* Safely execute function(arg), with png_error returning back here. */
+ if (setjmp(safe_jmpbuf) == 0)
{
-
image->opaque->error_buf = safe_jmpbuf;
result = function(arg);
+ image->opaque->error_buf = saved_error_buf;
+ return result;
}
+ /* On png_error, return via longjmp, pop the jmpbuf, and free the image. */
image->opaque->error_buf = saved_error_buf;
-
- /* And do the cleanup prior to any failure return. */
- if (result == 0)
- png_image_free(image);
-
- return result;
+ png_image_free(image);
+ return 0;
}
#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */
#endif /* READ || WRITE */
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c b/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c
index 6e510b27327..41e0a5abc3a 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c
@@ -29,7 +29,7 @@
* However, the following notice accompanied the original version of this
* file and, per its terms, should not be removed:
*
- * Copyright (c) 2018-2023 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -56,22 +56,22 @@ png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr,
* valid tRNS chunk in this case.
*/
if (flag == PNG_INFO_tRNS && png_ptr->num_trans == 0)
- return(0);
+ return 0;
#endif
- return(info_ptr->valid & flag);
+ return info_ptr->valid & flag;
}
- return(0);
+ return 0;
}
size_t PNGAPI
png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
- return(info_ptr->rowbytes);
+ return info_ptr->rowbytes;
- return(0);
+ return 0;
}
#ifdef PNG_INFO_IMAGE_SUPPORTED
@@ -79,9 +79,9 @@ png_bytepp PNGAPI
png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
- return(info_ptr->row_pointers);
+ return info_ptr->row_pointers;
- return(0);
+ return 0;
}
#endif
@@ -93,7 +93,7 @@ png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->width;
- return (0);
+ return 0;
}
png_uint_32 PNGAPI
@@ -102,7 +102,7 @@ png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->height;
- return (0);
+ return 0;
}
png_byte PNGAPI
@@ -111,7 +111,7 @@ png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->bit_depth;
- return (0);
+ return 0;
}
png_byte PNGAPI
@@ -120,7 +120,7 @@ png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->color_type;
- return (0);
+ return 0;
}
png_byte PNGAPI
@@ -129,7 +129,7 @@ png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->filter_type;
- return (0);
+ return 0;
}
png_byte PNGAPI
@@ -138,7 +138,7 @@ png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->interlace_type;
- return (0);
+ return 0;
}
png_byte PNGAPI
@@ -147,7 +147,7 @@ png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->compression_type;
- return (0);
+ return 0;
}
png_uint_32 PNGAPI
@@ -155,21 +155,20 @@ png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
info_ptr)
{
#ifdef PNG_pHYs_SUPPORTED
+ png_debug(1, "in png_get_x_pixels_per_meter");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0)
- {
- png_debug1(1, "in %s retrieval function",
- "png_get_x_pixels_per_meter");
-
- if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
- return (info_ptr->x_pixels_per_unit);
- }
+ {
+ if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
+ return info_ptr->x_pixels_per_unit;
+ }
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return (0);
+ return 0;
}
png_uint_32 PNGAPI
@@ -177,42 +176,41 @@ png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
info_ptr)
{
#ifdef PNG_pHYs_SUPPORTED
+ png_debug(1, "in png_get_y_pixels_per_meter");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0)
{
- png_debug1(1, "in %s retrieval function",
- "png_get_y_pixels_per_meter");
-
if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
- return (info_ptr->y_pixels_per_unit);
+ return info_ptr->y_pixels_per_unit;
}
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return (0);
+ return 0;
}
png_uint_32 PNGAPI
png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_pHYs_SUPPORTED
+ png_debug(1, "in png_get_pixels_per_meter");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0)
{
- png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
-
if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER &&
info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)
- return (info_ptr->x_pixels_per_unit);
+ return info_ptr->x_pixels_per_unit;
}
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return (0);
+ return 0;
}
#ifdef PNG_FLOATING_POINT_SUPPORTED
@@ -221,21 +219,21 @@ png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp
info_ptr)
{
#ifdef PNG_READ_pHYs_SUPPORTED
+ png_debug(1, "in png_get_pixel_aspect_ratio");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0)
{
- png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
-
if (info_ptr->x_pixels_per_unit != 0)
- return ((float)((float)info_ptr->y_pixels_per_unit
- /(float)info_ptr->x_pixels_per_unit));
+ return (float)info_ptr->y_pixels_per_unit
+ / (float)info_ptr->x_pixels_per_unit;
}
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return ((float)0.0);
+ return (float)0.0;
}
#endif
@@ -245,6 +243,8 @@ png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
png_const_inforp info_ptr)
{
#ifdef PNG_READ_pHYs_SUPPORTED
+ png_debug(1, "in png_get_pixel_aspect_ratio_fixed");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0 &&
info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 &&
@@ -253,8 +253,6 @@ png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
{
png_fixed_point res;
- png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed");
-
/* The following casts work because a PNG 4 byte integer only has a valid
* range of 0..2^31-1; otherwise the cast might overflow.
*/
@@ -275,80 +273,80 @@ png_int_32 PNGAPI
png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
+ png_debug(1, "in png_get_x_offset_microns");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_oFFs) != 0)
{
- png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
-
if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
- return (info_ptr->x_offset);
+ return info_ptr->x_offset;
}
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return (0);
+ return 0;
}
png_int_32 PNGAPI
png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
+ png_debug(1, "in png_get_y_offset_microns");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_oFFs) != 0)
{
- png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
-
if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
- return (info_ptr->y_offset);
+ return info_ptr->y_offset;
}
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return (0);
+ return 0;
}
png_int_32 PNGAPI
png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
+ png_debug(1, "in png_get_x_offset_pixels");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_oFFs) != 0)
{
- png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels");
-
if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
- return (info_ptr->x_offset);
+ return info_ptr->x_offset;
}
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return (0);
+ return 0;
}
png_int_32 PNGAPI
png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
+ png_debug(1, "in png_get_y_offset_pixels");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_oFFs) != 0)
{
- png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels");
-
if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
- return (info_ptr->y_offset);
+ return info_ptr->y_offset;
}
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return (0);
+ return 0;
}
#ifdef PNG_INCH_CONVERSIONS_SUPPORTED
@@ -462,11 +460,11 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
{
png_uint_32 retval = 0;
+ png_debug1(1, "in %s retrieval function", "pHYs");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0)
{
- png_debug1(1, "in %s retrieval function", "pHYs");
-
if (res_x != NULL)
{
*res_x = info_ptr->x_pixels_per_unit;
@@ -492,7 +490,7 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
}
}
- return (retval);
+ return retval;
}
#endif /* pHYs */
#endif /* INCH_CONVERSIONS */
@@ -506,9 +504,9 @@ png_byte PNGAPI
png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
- return(info_ptr->channels);
+ return info_ptr->channels;
- return (0);
+ return 0;
}
#ifdef PNG_READ_SUPPORTED
@@ -516,9 +514,9 @@ png_const_bytep PNGAPI
png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
- return(info_ptr->signature);
+ return info_ptr->signature;
- return (NULL);
+ return NULL;
}
#endif
@@ -527,17 +525,17 @@ png_uint_32 PNGAPI
png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
png_color_16p *background)
{
+ png_debug1(1, "in %s retrieval function", "bKGD");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_bKGD) != 0 &&
background != NULL)
{
- png_debug1(1, "in %s retrieval function", "bKGD");
-
*background = &(info_ptr->background);
- return (PNG_INFO_bKGD);
+ return PNG_INFO_bKGD;
}
- return (0);
+ return 0;
}
#endif
@@ -552,6 +550,8 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
double *white_x, double *white_y, double *red_x, double *red_y,
double *green_x, double *green_y, double *blue_x, double *blue_y)
{
+ png_debug1(1, "in %s retrieval function", "cHRM");
+
/* Quiet API change: this code used to only return the end points if a cHRM
* chunk was present, but the end points can also come from iCCP or sRGB
* chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and
@@ -561,8 +561,6 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
- png_debug1(1, "in %s retrieval function", "cHRM");
-
if (white_x != NULL)
*white_x = png_float(png_ptr,
info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
@@ -587,10 +585,10 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
if (blue_y != NULL)
*blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
"cHRM blue Y");
- return (PNG_INFO_cHRM);
+ return PNG_INFO_cHRM;
}
- return (0);
+ return 0;
}
png_uint_32 PNGAPI
@@ -599,11 +597,11 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
double *blue_Z)
{
+ png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
- png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
-
if (red_X != NULL)
*red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
"cHRM red X");
@@ -631,10 +629,10 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
if (blue_Z != NULL)
*blue_Z = png_float(png_ptr,
info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
- return (PNG_INFO_cHRM);
+ return PNG_INFO_cHRM;
}
- return (0);
+ return 0;
}
# endif
@@ -647,11 +645,11 @@ png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
png_fixed_point *int_blue_Z)
{
+ png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
- png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
-
if (int_red_X != NULL)
*int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;
if (int_red_Y != NULL)
@@ -670,10 +668,10 @@ png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
*int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y;
if (int_blue_Z != NULL)
*int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z;
- return (PNG_INFO_cHRM);
+ return PNG_INFO_cHRM;
}
- return (0);
+ return 0;
}
png_uint_32 PNGAPI
@@ -703,10 +701,10 @@ png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
*blue_x = info_ptr->colorspace.end_points_xy.bluex;
if (blue_y != NULL)
*blue_y = info_ptr->colorspace.end_points_xy.bluey;
- return (PNG_INFO_cHRM);
+ return PNG_INFO_cHRM;
}
- return (0);
+ return 0;
}
# endif
#endif
@@ -724,10 +722,10 @@ png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
file_gamma != NULL)
{
*file_gamma = info_ptr->colorspace.gamma;
- return (PNG_INFO_gAMA);
+ return PNG_INFO_gAMA;
}
- return (0);
+ return 0;
}
# endif
@@ -744,10 +742,10 @@ png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
{
*file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
"png_get_gAMA");
- return (PNG_INFO_gAMA);
+ return PNG_INFO_gAMA;
}
- return (0);
+ return 0;
}
# endif
#endif
@@ -763,10 +761,10 @@ png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
(info_ptr->valid & PNG_INFO_sRGB) != 0 && file_srgb_intent != NULL)
{
*file_srgb_intent = info_ptr->colorspace.rendering_intent;
- return (PNG_INFO_sRGB);
+ return PNG_INFO_sRGB;
}
- return (0);
+ return 0;
}
#endif
@@ -790,10 +788,10 @@ png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
*/
if (compression_type != NULL)
*compression_type = PNG_COMPRESSION_TYPE_BASE;
- return (PNG_INFO_iCCP);
+ return PNG_INFO_iCCP;
}
- return (0);
+ return 0;
}
#endif
@@ -803,13 +801,15 @@ int PNGAPI
png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
png_sPLT_tpp spalettes)
{
+ png_debug1(1, "in %s retrieval function", "sPLT");
+
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
{
*spalettes = info_ptr->splt_palettes;
return info_ptr->splt_palettes_num;
}
- return (0);
+ return 0;
}
#endif
@@ -835,10 +835,10 @@ png_get_eXIf_1(png_const_structrp png_ptr, png_const_inforp info_ptr,
{
*num_exif = info_ptr->num_exif;
*exif = info_ptr->exif;
- return (PNG_INFO_eXIf);
+ return PNG_INFO_eXIf;
}
- return (0);
+ return 0;
}
#endif
@@ -853,10 +853,10 @@ png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
(info_ptr->valid & PNG_INFO_hIST) != 0 && hist != NULL)
{
*hist = info_ptr->hist;
- return (PNG_INFO_hIST);
+ return PNG_INFO_hIST;
}
- return (0);
+ return 0;
}
#endif
@@ -869,7 +869,7 @@ png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_debug1(1, "in %s retrieval function", "IHDR");
if (png_ptr == NULL || info_ptr == NULL)
- return (0);
+ return 0;
if (width != NULL)
*width = info_ptr->width;
@@ -901,7 +901,7 @@ png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
info_ptr->compression_type, info_ptr->filter_type);
- return (1);
+ return 1;
}
#ifdef PNG_oFFs_SUPPORTED
@@ -918,10 +918,10 @@ png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
*offset_x = info_ptr->x_offset;
*offset_y = info_ptr->y_offset;
*unit_type = (int)info_ptr->offset_unit_type;
- return (PNG_INFO_oFFs);
+ return PNG_INFO_oFFs;
}
- return (0);
+ return 0;
}
#endif
@@ -945,10 +945,10 @@ png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
*nparams = (int)info_ptr->pcal_nparams;
*units = info_ptr->pcal_units;
*params = info_ptr->pcal_params;
- return (PNG_INFO_pCAL);
+ return PNG_INFO_pCAL;
}
- return (0);
+ return 0;
}
#endif
@@ -960,6 +960,8 @@ png_uint_32 PNGAPI
png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, png_fixed_point *width, png_fixed_point *height)
{
+ png_debug1(1, "in %s retrieval function", "sCAL");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_sCAL) != 0)
{
@@ -971,10 +973,10 @@ png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
*width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
*height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
"sCAL height");
- return (PNG_INFO_sCAL);
+ return PNG_INFO_sCAL;
}
- return(0);
+ return 0;
}
# endif /* FLOATING_ARITHMETIC */
# endif /* FIXED_POINT */
@@ -983,32 +985,36 @@ png_uint_32 PNGAPI
png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, double *width, double *height)
{
+ png_debug1(1, "in %s retrieval function", "sCAL(float)");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_sCAL) != 0)
{
*unit = info_ptr->scal_unit;
*width = atof(info_ptr->scal_s_width);
*height = atof(info_ptr->scal_s_height);
- return (PNG_INFO_sCAL);
+ return PNG_INFO_sCAL;
}
- return(0);
+ return 0;
}
# endif /* FLOATING POINT */
png_uint_32 PNGAPI
png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, png_charpp width, png_charpp height)
{
+ png_debug1(1, "in %s retrieval function", "sCAL(str)");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_sCAL) != 0)
{
*unit = info_ptr->scal_unit;
*width = info_ptr->scal_s_width;
*height = info_ptr->scal_s_height;
- return (PNG_INFO_sCAL);
+ return PNG_INFO_sCAL;
}
- return(0);
+ return 0;
}
#endif /* sCAL */
@@ -1043,7 +1049,7 @@ png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
}
}
- return (retval);
+ return retval;
}
#endif /* pHYs */
@@ -1059,10 +1065,10 @@ png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,
*palette = info_ptr->palette;
*num_palette = info_ptr->num_palette;
png_debug1(3, "num_palette = %d", *num_palette);
- return (PNG_INFO_PLTE);
+ return PNG_INFO_PLTE;
}
- return (0);
+ return 0;
}
#ifdef PNG_sBIT_SUPPORTED
@@ -1076,10 +1082,10 @@ png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
(info_ptr->valid & PNG_INFO_sBIT) != 0 && sig_bit != NULL)
{
*sig_bit = &(info_ptr->sig_bit);
- return (PNG_INFO_sBIT);
+ return PNG_INFO_sBIT;
}
- return (0);
+ return 0;
}
#endif
@@ -1090,7 +1096,7 @@ png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
{
- png_debug1(1, "in 0x%lx retrieval function",
+ png_debug1(1, "in text retrieval function, chunk typeid = 0x%lx",
(unsigned long)png_ptr->chunk_name);
if (text_ptr != NULL)
@@ -1105,7 +1111,7 @@ png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
if (num_text != NULL)
*num_text = 0;
- return(0);
+ return 0;
}
#endif
@@ -1120,10 +1126,10 @@ png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
(info_ptr->valid & PNG_INFO_tIME) != 0 && mod_time != NULL)
{
*mod_time = &(info_ptr->mod_time);
- return (PNG_INFO_tIME);
+ return PNG_INFO_tIME;
}
- return (0);
+ return 0;
}
#endif
@@ -1133,11 +1139,12 @@ png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
{
png_uint_32 retval = 0;
+
+ png_debug1(1, "in %s retrieval function", "tRNS");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_tRNS) != 0)
{
- png_debug1(1, "in %s retrieval function", "tRNS");
-
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
if (trans_alpha != NULL)
@@ -1169,7 +1176,7 @@ png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
}
}
- return (retval);
+ return retval;
}
#endif
@@ -1184,7 +1191,7 @@ png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
return info_ptr->unknown_chunks_num;
}
- return (0);
+ return 0;
}
#endif
@@ -1280,7 +1287,7 @@ png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return png_ptr->num_palette_max;
- return (-1);
+ return -1;
}
# endif
#endif
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h b/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h
index e98d49cf0cc..e238ccdb9a4 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h
@@ -31,7 +31,7 @@
* However, the following notice accompanied the original version of this
* file and, per its terms, should not be removed:
*/
-/* libpng version 1.6.40 */
+/* libpng version 1.6.43 */
/* Copyright (c) 2018-2023 Cosmin Truta */
/* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngpread.c b/src/java.desktop/share/native/libsplashscreen/libpng/pngpread.c
index a98b2013256..816631cae18 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/pngpread.c
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngpread.c
@@ -29,7 +29,7 @@
* However, the following notice accompanied the original version of this
* file and, per its terms, should not be removed:
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -173,10 +173,10 @@ png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr)
num_to_check);
png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check);
- if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
+ if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check) != 0)
{
if (num_checked < 4 &&
- png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
+ png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4) != 0)
png_error(png_ptr, "Not a PNG file");
else
@@ -322,6 +322,14 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
}
+#endif
+#ifdef PNG_READ_eXIf_SUPPORTED
+ else if (png_ptr->chunk_name == png_eXIf)
+ {
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
+ png_handle_eXIf(png_ptr, info_ptr, png_ptr->push_length);
+ }
+
#endif
#ifdef PNG_READ_sRGB_SUPPORTED
else if (chunk_name == png_sRGB)
@@ -1117,7 +1125,7 @@ png_voidp PNGAPI
png_get_progressive_ptr(png_const_structrp png_ptr)
{
if (png_ptr == NULL)
- return (NULL);
+ return NULL;
return png_ptr->io_ptr;
}
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h b/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h
index 914d0b97b1d..18424542b00 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h
@@ -29,7 +29,7 @@
* However, the following notice accompanied the original version of this
* file and, per its terms, should not be removed:
*
- * Copyright (c) 2018-2023 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -64,7 +64,7 @@
* still required (as of 2011-05-02.)
*/
#ifndef _POSIX_SOURCE
-# define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
+# define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
#endif
#ifndef PNG_VERSION_INFO_ONLY
@@ -218,13 +218,27 @@
#endif /* PNG_ARM_NEON_OPT > 0 */
#ifndef PNG_MIPS_MSA_OPT
-# if defined(__mips_msa) && (__mips_isa_rev >= 5) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
+# if defined(__mips_msa) && (__mips_isa_rev >= 5) && \
+ defined(PNG_ALIGNED_MEMORY_SUPPORTED)
# define PNG_MIPS_MSA_OPT 2
# else
# define PNG_MIPS_MSA_OPT 0
# endif
#endif
+#ifndef PNG_MIPS_MMI_OPT
+# ifdef PNG_MIPS_MMI
+# if defined(__mips_loongson_mmi) && (_MIPS_SIM == _ABI64) && \
+ defined(PNG_ALIGNED_MEMORY_SUPPORTED)
+# define PNG_MIPS_MMI_OPT 1
+# else
+# define PNG_MIPS_MMI_OPT 0
+# endif
+# else
+# define PNG_MIPS_MMI_OPT 0
+# endif
+#endif
+
#ifndef PNG_POWERPC_VSX_OPT
# if defined(__PPC64__) && defined(__ALTIVEC__) && defined(__VSX__)
# define PNG_POWERPC_VSX_OPT 2
@@ -233,13 +247,21 @@
# endif
#endif
+#ifndef PNG_LOONGARCH_LSX_OPT
+# if defined(__loongarch_sx)
+# define PNG_LOONGARCH_LSX_OPT 1
+# else
+# define PNG_LOONGARCH_LSX_OPT 0
+# endif
+#endif
+
#ifndef PNG_INTEL_SSE_OPT
# ifdef PNG_INTEL_SSE
/* Only check for SSE if the build configuration has been modified to
* enable SSE optimizations. This means that these optimizations will
* be off by default. See contrib/intel for more details.
*/
-# if defined(__SSE4_1__) || defined(__AVX__) || defined(__SSSE3__) || \
+# if defined(__SSE4_1__) || defined(__AVX__) || defined(__SSSE3__) || \
defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \
(defined(_M_IX86_FP) && _M_IX86_FP >= 2)
# define PNG_INTEL_SSE_OPT 1
@@ -276,7 +298,6 @@
#endif
#if PNG_MIPS_MSA_OPT > 0
-# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_msa
# ifndef PNG_MIPS_MSA_IMPLEMENTATION
# if defined(__mips_msa)
# if defined(__clang__)
@@ -292,11 +313,28 @@
# ifndef PNG_MIPS_MSA_IMPLEMENTATION
# define PNG_MIPS_MSA_IMPLEMENTATION 1
+# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_mips
# endif
#else
# define PNG_MIPS_MSA_IMPLEMENTATION 0
#endif /* PNG_MIPS_MSA_OPT > 0 */
+#if PNG_MIPS_MMI_OPT > 0
+# ifndef PNG_MIPS_MMI_IMPLEMENTATION
+# if defined(__mips_loongson_mmi) && (_MIPS_SIM == _ABI64)
+# define PNG_MIPS_MMI_IMPLEMENTATION 2
+# else /* !defined __mips_loongson_mmi || _MIPS_SIM != _ABI64 */
+# define PNG_MIPS_MMI_IMPLEMENTATION 0
+# endif /* __mips_loongson_mmi && _MIPS_SIM == _ABI64 */
+# endif /* !PNG_MIPS_MMI_IMPLEMENTATION */
+
+# if PNG_MIPS_MMI_IMPLEMENTATION > 0
+# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_mips
+# endif
+#else
+# define PNG_MIPS_MMI_IMPLEMENTATION 0
+#endif /* PNG_MIPS_MMI_OPT > 0 */
+
#if PNG_POWERPC_VSX_OPT > 0
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_vsx
# define PNG_POWERPC_VSX_IMPLEMENTATION 1
@@ -304,6 +342,12 @@
# define PNG_POWERPC_VSX_IMPLEMENTATION 0
#endif
+#if PNG_LOONGARCH_LSX_OPT > 0
+# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_lsx
+# define PNG_LOONGARCH_LSX_IMPLEMENTATION 1
+#else
+# define PNG_LOONGARCH_LSX_IMPLEMENTATION 0
+#endif
/* Is this a build of a DLL where compilation of the object modules requires
* different preprocessor settings to those required for a simple library? If
@@ -542,18 +586,8 @@
*/
# include
-# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
- defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
- /* We need to check that hasn't already been included earlier
- * as it seems it doesn't agree with , yet we should really use
- * if possible.
- */
-# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
-# include
-# endif
-# else
-# include
-# endif
+# include
+
# if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
/* Amiga SAS/C: We must include builtin FPU functions when compiling using
* MATH=68881
@@ -1334,7 +1368,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
#endif
-#if PNG_MIPS_MSA_OPT > 0
+#if PNG_MIPS_MSA_IMPLEMENTATION == 1
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_msa,(png_row_infop row_info,
png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_msa,(png_row_infop
@@ -1351,6 +1385,23 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_msa,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
#endif
+#if PNG_MIPS_MMI_IMPLEMENTATION > 0
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_mmi,(png_row_infop row_info,
+ png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_mmi,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_mmi,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_mmi,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_mmi,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_mmi,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_mmi,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+#endif
+
#if PNG_POWERPC_VSX_OPT > 0
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_vsx,(png_row_infop row_info,
png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
@@ -1383,6 +1434,23 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_sse2,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
#endif
+#if PNG_LOONGARCH_LSX_IMPLEMENTATION == 1
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_lsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_lsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_lsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_lsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_lsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_lsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_lsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+#endif
+
/* Choose the best filter to use and filter the row data */
PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,
png_row_infop row_info),PNG_EMPTY);
@@ -2122,17 +2190,27 @@ PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
#endif
-#if PNG_MIPS_MSA_OPT > 0
-PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa,
+#if PNG_MIPS_MSA_IMPLEMENTATION == 1
+PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_mips,
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
#endif
+# if PNG_MIPS_MMI_IMPLEMENTATION > 0
+PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_mips,
+ (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
+# endif
+
# if PNG_INTEL_SSE_IMPLEMENTATION > 0
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2,
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
# endif
#endif
+#if PNG_LOONGARCH_LSX_OPT > 0
+PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_lsx,
+ (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
+#endif
+
PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
png_const_charp key, png_bytep new_key), PNG_EMPTY);
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c b/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c
index 3631e60f36b..e9e94477545 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c
@@ -29,7 +29,7 @@
* However, the following notice accompanied the original version of this
* file and, per its terms, should not be removed:
*
- * Copyright (c) 2018-2019 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -596,7 +596,11 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
#endif
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
- if (png_ptr->transformations)
+ if (png_ptr->transformations
+# ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
+ || png_ptr->num_palette_max >= 0
+# endif
+ )
png_do_read_transformations(png_ptr, &row_info);
#endif
@@ -813,7 +817,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
/* Report invalid palette index; added at libng-1.5.10 */
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
- png_ptr->num_palette_max > png_ptr->num_palette)
+ png_ptr->num_palette_max >= png_ptr->num_palette)
png_benign_error(png_ptr, "Read palette index exceeding num_palette");
#endif
@@ -1077,6 +1081,8 @@ void PNGAPI
png_read_png(png_structrp png_ptr, png_inforp info_ptr,
int transforms, voidp params)
{
+ png_debug(1, "in png_read_png");
+
if (png_ptr == NULL || info_ptr == NULL)
return;
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c b/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c
index 843eb5fff2a..a393de4b79d 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c
@@ -29,7 +29,7 @@
* However, the following notice accompanied the original version of this
* file and, per its terms, should not be removed:
*
- * Copyright (c) 2018-2019 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -318,21 +318,20 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
int compose = 0;
png_fixed_point file_gamma;
- png_debug(1, "in png_set_alpha_mode");
+ png_debug(1, "in png_set_alpha_mode_fixed");
if (png_rtran_ok(png_ptr, 0) == 0)
return;
output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);
- /* Validate the value to ensure it is in a reasonable range. The value
+ /* Validate the value to ensure it is in a reasonable range. The value
* is expected to be 1 or greater, but this range test allows for some
- * viewing correction values. The intent is to weed out users of this API
- * who use the inverse of the gamma value accidentally! Since some of these
- * values are reasonable this may have to be changed:
+ * viewing correction values. The intent is to weed out the API users
+ * who might use the inverse of the gamma value accidentally!
*
- * 1.6.x: changed from 0.07..3 to 0.01..100 (to accommodate the optimal 16-bit
- * gamma of 36, and its reciprocal.)
+ * In libpng 1.6.0, we changed from 0.07..3 to 0.01..100, to accommodate
+ * the optimal 16-bit gamma of 36 and its reciprocal.
*/
if (output_gamma < 1000 || output_gamma > 10000000)
png_error(png_ptr, "output gamma out of expected range");
@@ -469,7 +468,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
int i;
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
- (png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte))));
+ (png_alloc_size_t)num_palette);
for (i = 0; i < num_palette; i++)
png_ptr->quantize_index[i] = (png_byte)i;
}
@@ -486,7 +485,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
/* Initialize an array to sort colors */
png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
- (png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte))));
+ (png_alloc_size_t)num_palette);
/* Initialize the quantize_sort array */
for (i = 0; i < num_palette; i++)
@@ -620,11 +619,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
/* Initialize palette index arrays */
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
- (png_alloc_size_t)((png_uint_32)num_palette *
- (sizeof (png_byte))));
+ (png_alloc_size_t)num_palette);
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
- (png_alloc_size_t)((png_uint_32)num_palette *
- (sizeof (png_byte))));
+ (png_alloc_size_t)num_palette);
/* Initialize the sort array */
for (i = 0; i < num_palette; i++)
@@ -789,12 +786,11 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
size_t num_entries = ((size_t)1 << total_bits);
png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
- (png_alloc_size_t)(num_entries * (sizeof (png_byte))));
+ (png_alloc_size_t)(num_entries));
- distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)(num_entries *
- (sizeof (png_byte))));
+ distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)num_entries);
- memset(distance, 0xff, num_entries * (sizeof (png_byte)));
+ memset(distance, 0xff, num_entries);
for (i = 0; i < num_palette; i++)
{
@@ -998,7 +994,7 @@ void PNGFAPI
png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
png_fixed_point red, png_fixed_point green)
{
- png_debug(1, "in png_set_rgb_to_gray");
+ png_debug(1, "in png_set_rgb_to_gray_fixed");
/* Need the IHDR here because of the check on color_type below. */
/* TODO: fix this */
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c b/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c
index 524297c5a10..5280140d12b 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c
@@ -29,7 +29,7 @@
* However, the following notice accompanied the original version of this
* file and, per its terms, should not be removed:
*
- * Copyright (c) 2018-2022 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -54,7 +54,7 @@ png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf)
if (uval > PNG_UINT_31_MAX)
png_error(png_ptr, "PNG unsigned integer out of range");
- return (uval);
+ return uval;
}
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED)
@@ -168,7 +168,7 @@ png_read_sig(png_structrp png_ptr, png_inforp info_ptr)
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check) != 0)
{
if (num_checked < 4 &&
- png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
+ png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4) != 0)
png_error(png_ptr, "Not a PNG file");
else
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
@@ -199,7 +199,7 @@ png_read_chunk_header(png_structrp png_ptr)
/* Put the chunk name into png_ptr->chunk_name. */
png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(buf+4);
- png_debug2(0, "Reading %lx chunk, length = %lu",
+ png_debug2(0, "Reading chunk typeid = 0x%lx, length = %lu",
(unsigned long)png_ptr->chunk_name, (unsigned long)length);
/* Reset the crc and run it over the chunk name. */
@@ -266,10 +266,10 @@ png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
else
png_chunk_error(png_ptr, "CRC error");
- return (1);
+ return 1;
}
- return (0);
+ return 0;
}
/* Compare the CRC stored in the PNG file with that calculated by libpng from
@@ -305,11 +305,11 @@ png_crc_error(png_structrp png_ptr)
if (need_crc != 0)
{
crc = png_get_uint_32(crc_bytes);
- return ((int)(crc != png_ptr->crc));
+ return crc != png_ptr->crc;
}
else
- return (0);
+ return 0;
}
#if defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) ||\
@@ -449,8 +449,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;
}
-#if ZLIB_VERNUM >= 0x1290 && \
- defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_IGNORE_ADLER32)
+#ifdef PNG_DISABLE_ADLER32_CHECK_SUPPORTED
if (((png_ptr->options >> PNG_IGNORE_ADLER32) & 3) == PNG_OPTION_ON)
/* Turn off validation of the ADLER32 checksum in IDAT chunks */
ret = inflateValidate(&png_ptr->zstream, 0);
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c b/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c
index 62612a02278..f53ab6fa1d1 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c
@@ -29,7 +29,7 @@
* However, the following notice accompanied the original version of this
* file and, per its terms, should not be removed:
*
- * Copyright (c) 2018-2023 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -791,11 +791,11 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
{
int i;
- png_debug1(1, "in %lx storage function", png_ptr == NULL ? 0xabadca11U :
- (unsigned long)png_ptr->chunk_name);
+ png_debug1(1, "in text storage function, chunk typeid = 0x%lx",
+ png_ptr == NULL ? 0xabadca11UL : (unsigned long)png_ptr->chunk_name);
if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL)
- return(0);
+ return 0;
/* Make sure we have enough space in the "text" array in info_struct
* to hold all of the incoming text_ptr objects. This compare can't overflow
@@ -975,7 +975,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
png_debug1(3, "transferred text chunk %d", info_ptr->num_text);
}
- return(0);
+ return 0;
}
#endif
@@ -1091,6 +1091,8 @@ png_set_sPLT(png_const_structrp png_ptr,
{
png_sPLT_tp np;
+ png_debug1(1, "in %s storage function", "sPLT");
+
if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 || entries == NULL)
return;
@@ -1565,7 +1567,7 @@ void PNGAPI
png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr,
png_bytepp row_pointers)
{
- png_debug1(1, "in %s storage function", "rows");
+ png_debug(1, "in png_set_rows");
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -1584,6 +1586,8 @@ png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr,
void PNGAPI
png_set_compression_buffer_size(png_structrp png_ptr, size_t size)
{
+ png_debug(1, "in png_set_compression_buffer_size");
+
if (png_ptr == NULL)
return;
@@ -1655,6 +1659,8 @@ void PNGAPI
png_set_user_limits(png_structrp png_ptr, png_uint_32 user_width_max,
png_uint_32 user_height_max)
{
+ png_debug(1, "in png_set_user_limits");
+
/* Images with dimensions larger than these limits will be
* rejected by png_set_IHDR(). To accept any PNG datastream
* regardless of dimensions, set both limits to 0x7fffffff.
@@ -1670,6 +1676,8 @@ png_set_user_limits(png_structrp png_ptr, png_uint_32 user_width_max,
void PNGAPI
png_set_chunk_cache_max(png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
{
+ png_debug(1, "in png_set_chunk_cache_max");
+
if (png_ptr != NULL)
png_ptr->user_chunk_cache_max = user_chunk_cache_max;
}
@@ -1679,6 +1687,8 @@ void PNGAPI
png_set_chunk_malloc_max(png_structrp png_ptr,
png_alloc_size_t user_chunk_malloc_max)
{
+ png_debug(1, "in png_set_chunk_malloc_max");
+
if (png_ptr != NULL)
png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
}
diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngtrans.c b/src/java.desktop/share/native/libsplashscreen/libpng/pngtrans.c
index 89a62191b6f..2350057e70e 100644
--- a/src/java.desktop/share/native/libsplashscreen/libpng/pngtrans.c
+++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngtrans.c
@@ -29,7 +29,7 @@
* However, the following notice accompanied the original version of this
* file and, per its terms, should not be removed:
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -131,10 +131,10 @@ png_set_interlace_handling(png_structrp png_ptr)
if (png_ptr != 0 && png_ptr->interlaced != 0)
{
png_ptr->transformations |= PNG_INTERLACE;
- return (7);
+ return 7;
}
- return (1);
+ return 1;
}
#endif
@@ -526,6 +526,8 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
png_bytep dp = row; /* destination pointer */
png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */
+ png_debug(1, "in png_do_strip_channel");
+
/* At the start sp will point to the first byte to copy and dp to where
* it is copied to. ep always points just beyond the end of the row, so
* the loop simply copies (channels-1) channels until sp reaches ep.
@@ -726,6 +728,8 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
void /* PRIVATE */
png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
{
+ png_debug(1, "in png_do_check_palette_indexes");
+
if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
{
@@ -736,7 +740,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
* forms produced on either GCC or MSVC.
*/
int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width);
- png_bytep rp = png_ptr->row_buf + row_info->rowbytes - 1;
+ png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
switch (row_info->bit_depth)
{
@@ -861,7 +865,7 @@ png_voidp PNGAPI
png_get_user_transform_ptr(png_const_structrp png_ptr)
{
if (png_ptr == NULL)
- return (NULL);
+ return NULL;
return png_ptr->user_transform_ptr;
}
diff --git a/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java b/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java
index ebf4950c49a..edb82719788 100644
--- a/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java
+++ b/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java
@@ -341,7 +341,8 @@ public void handlePropertyNotify(XEvent xev) {
|| ev.get_atom() == XWM.XA_NET_FRAME_EXTENTS.getAtom())
{
if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) {
- if (getMWMDecorTitleProperty().isPresent()) {
+ if ((XWM.getWMID() == XWM.MUTTER_WM && !isTargetUndecorated() && isVisible())
+ || getMWMDecorTitleProperty().isPresent()) {
// Insets might have changed "in-flight" if that property
// is present, so we need to get the actual values of
// insets from the WM and propagate them through all the
diff --git a/src/java.desktop/unix/classes/sun/awt/X11/XWM.java b/src/java.desktop/unix/classes/sun/awt/X11/XWM.java
index 43c6a2c4832..dbd9c42bb0c 100644
--- a/src/java.desktop/unix/classes/sun/awt/X11/XWM.java
+++ b/src/java.desktop/unix/classes/sun/awt/X11/XWM.java
@@ -1369,6 +1369,9 @@ Insets guessInsets(XDecoratedPeer window) {
case UNITY_COMPIZ_WM:
res = new Insets(28, 1, 1, 1);
break;
+ case MUTTER_WM:
+ res = new Insets(37, 0, 0, 0);
+ break;
case MOTIF_WM:
case OPENLOOK_WM:
default:
@@ -1380,6 +1383,7 @@ Insets guessInsets(XDecoratedPeer window) {
}
return res;
}
+
/*
* Some buggy WMs ignore window gravity when processing
* ConfigureRequest and position window as if the gravity is Static.
diff --git a/src/java.desktop/unix/classes/sun/awt/screencast/ScreencastHelper.java b/src/java.desktop/unix/classes/sun/awt/screencast/ScreencastHelper.java
index e61fd1a90e6..78661587554 100644
--- a/src/java.desktop/unix/classes/sun/awt/screencast/ScreencastHelper.java
+++ b/src/java.desktop/unix/classes/sun/awt/screencast/ScreencastHelper.java
@@ -26,15 +26,20 @@
package sun.awt.screencast;
import sun.awt.UNIXToolkit;
+import sun.java2d.pipe.Region;
import sun.security.action.GetPropertyAction;
+import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Toolkit;
+import java.awt.geom.AffineTransform;
import java.security.AccessController;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
import java.util.stream.IntStream;
/**
@@ -54,6 +59,13 @@ public class ScreencastHelper {
private static final int DENIED = -11;
private static final int OUT_OF_BOUNDS = -12;
+ private static final int DELAY_BEFORE_SESSION_CLOSE = 2000;
+
+ private static volatile TimerTask timerTask = null;
+ private static final Timer timerCloseSession
+ = new Timer("auto-close screencast session", true);
+
+
private ScreencastHelper() {
}
@@ -100,9 +112,37 @@ private static List getSystemScreensBounds() {
.stream(GraphicsEnvironment
.getLocalGraphicsEnvironment()
.getScreenDevices())
- .map(graphicsDevice ->
- graphicsDevice.getDefaultConfiguration().getBounds()
- ).toList();
+ .map(graphicsDevice -> {
+ GraphicsConfiguration gc =
+ graphicsDevice.getDefaultConfiguration();
+ Rectangle screen = gc.getBounds();
+ AffineTransform tx = gc.getDefaultTransform();
+
+ return new Rectangle(
+ Region.clipRound(screen.x * tx.getScaleX()),
+ Region.clipRound(screen.y * tx.getScaleY()),
+ Region.clipRound(screen.width * tx.getScaleX()),
+ Region.clipRound(screen.height * tx.getScaleY())
+ );
+ })
+ .toList();
+ }
+
+ private static synchronized native void closeSession();
+
+ private static void timerCloseSessionRestart() {
+ if (timerTask != null) {
+ timerTask.cancel();
+ }
+
+ timerTask = new TimerTask() {
+ @Override
+ public void run() {
+ closeSession();
+ }
+ };
+
+ timerCloseSession.schedule(timerTask, DELAY_BEFORE_SESSION_CLOSE);
}
public static synchronized void getRGBPixels(
@@ -110,6 +150,8 @@ public static synchronized void getRGBPixels(
) {
if (!IS_NATIVE_LOADED) return;
+ timerCloseSessionRestart();
+
Rectangle captureArea = new Rectangle(x, y, width, height);
List affectedScreenBounds = getSystemScreensBounds()
diff --git a/src/java.desktop/unix/classes/sun/awt/screencast/TokenStorage.java b/src/java.desktop/unix/classes/sun/awt/screencast/TokenStorage.java
index 022ca5e7dbb..3daf9b2a8b8 100644
--- a/src/java.desktop/unix/classes/sun/awt/screencast/TokenStorage.java
+++ b/src/java.desktop/unix/classes/sun/awt/screencast/TokenStorage.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,8 @@
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import java.nio.file.attribute.PosixFilePermission;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -58,6 +60,7 @@
* The restore token allows the ScreenCast session to be restored
* with previously granted screen access permissions.
*/
+@SuppressWarnings("removal")
final class TokenStorage {
private TokenStorage() {}
@@ -69,8 +72,24 @@ private TokenStorage() {}
private static final Path PROPS_PATH;
private static final Path PROP_FILENAME;
+ private static void doPrivilegedRunnable(Runnable runnable) {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
+ public Void run() {
+ runnable.run();
+ return null;
+ }
+ });
+ }
+
static {
- PROPS_PATH = setupPath();
+ PROPS_PATH = AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
+ public Path run() {
+ return setupPath();
+ }
+ });
+
if (PROPS_PATH != null) {
PROP_FILENAME = PROPS_PATH.getFileName();
if (SCREENCAST_DEBUG) {
@@ -192,9 +211,9 @@ public void run() {
}
if (kind == ENTRY_CREATE) {
- setFilePermission(PROPS_PATH);
+ doPrivilegedRunnable(() -> setFilePermission(PROPS_PATH));
} else if (kind == ENTRY_MODIFY) {
- readTokens(PROPS_PATH);
+ doPrivilegedRunnable(() -> readTokens(PROPS_PATH));
} else if (kind == ENTRY_DELETE) {
synchronized (PROPS) {
PROPS.clear();
@@ -207,24 +226,31 @@ public void run() {
}
}
+ private static WatchService watchService;
+
private static void setupWatch() {
- try {
- WatchService watchService =
- FileSystems.getDefault().newWatchService();
+ doPrivilegedRunnable(() -> {
+ try {
+ watchService =
+ FileSystems.getDefault().newWatchService();
- PROPS_PATH
- .getParent()
- .register(watchService,
- ENTRY_CREATE,
- ENTRY_DELETE,
- ENTRY_MODIFY);
+ PROPS_PATH
+ .getParent()
+ .register(watchService,
+ ENTRY_CREATE,
+ ENTRY_DELETE,
+ ENTRY_MODIFY);
- new WatcherThread(watchService).start();
- } catch (Exception e) {
- if (SCREENCAST_DEBUG) {
- System.err.printf("Token storage: failed to setup " +
- "file watch %s\n", e);
+ } catch (Exception e) {
+ if (SCREENCAST_DEBUG) {
+ System.err.printf("Token storage: failed to setup " +
+ "file watch %s\n", e);
+ }
}
+ });
+
+ if (watchService != null) {
+ new WatcherThread(watchService).start();
}
}
@@ -276,7 +302,7 @@ private static void storeTokenFromNative(String oldToken,
}
if (changed) {
- store("save tokens");
+ doPrivilegedRunnable(() -> store("save tokens"));
}
}
}
@@ -324,10 +350,14 @@ static Set getTokens(List affectedScreenBounds) {
return tokenItem;
})
.filter(Objects::nonNull)
+ .sorted((t1, t2) -> //Token with more screens preferred
+ t2.allowedScreensBounds.size()
+ - t1.allowedScreensBounds.size()
+ )
.toList();
}
- removeMalformedRecords(malformed);
+ doPrivilegedRunnable(() -> removeMalformedRecords(malformed));
// 1. Try to find exact matches
for (TokenItem tokenItem : allTokenItems) {
@@ -365,6 +395,17 @@ static Set getTokens(List