Skip to content

Commit a9ee8ba

Browse files
committedJun 5, 2024
8328999: Update GIFlib to 5.2.2
Backport-of: 6969a9e0b2143eee5a7cfa02460a8ab6dfa08cda
1 parent 1cec5b1 commit a9ee8ba

File tree

8 files changed

+741
-667
lines changed

8 files changed

+741
-667
lines changed
 

‎src/java.desktop/share/legal/giflib.md

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## GIFLIB v5.2.1
1+
## GIFLIB v5.2.2
22

33
### GIFLIB License
44
```
@@ -24,7 +24,27 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
THE SOFTWARE.
2525
2626
27-
https://sourceforge.net/p/giflib/code/ci/master/tree/openbsd-reallocarray.c
27+
tree/README
2828
29-
Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>
29+
== Authors ==
30+
31+
Gershon Elber <gershon[AT]cs.technion.sc.il>
32+
original giflib code
33+
34+
Toshio Kuratomi <toshio[AT]tiki-lounge.com>
35+
uncompressed gif writing code
36+
former maintainer
37+
38+
Eric Raymond <esr[AT]snark.thyrsus.com>
39+
current as well as long time former maintainer of giflib code
40+
41+
There have been many other contributors; see the attributions in the
42+
version-control history to learn more.
43+
44+
45+
tree/openbsd-reallocarray.c
46+
47+
Copyright (C) 2008 Otto Moerbeek <otto@drijf.net>
3048
SPDX-License-Identifier: MIT
49+
50+
```

‎src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c

+413-342
Large diffs are not rendered by default.

‎src/java.desktop/share/native/libsplashscreen/giflib/gif_err.c

+25-27
Original file line numberDiff line numberDiff line change
@@ -38,82 +38,80 @@ SPDX-License-Identifier: MIT
3838
/*****************************************************************************
3939
Return a string description of the last GIF error
4040
*****************************************************************************/
41-
const char *
42-
GifErrorString(int ErrorCode)
43-
{
41+
const char *GifErrorString(int ErrorCode) {
4442
const char *Err;
4543

4644
switch (ErrorCode) {
47-
case E_GIF_ERR_OPEN_FAILED:
45+
case E_GIF_ERR_OPEN_FAILED:
4846
Err = "Failed to open given file";
4947
break;
50-
case E_GIF_ERR_WRITE_FAILED:
48+
case E_GIF_ERR_WRITE_FAILED:
5149
Err = "Failed to write to given file";
5250
break;
53-
case E_GIF_ERR_HAS_SCRN_DSCR:
51+
case E_GIF_ERR_HAS_SCRN_DSCR:
5452
Err = "Screen descriptor has already been set";
5553
break;
56-
case E_GIF_ERR_HAS_IMAG_DSCR:
54+
case E_GIF_ERR_HAS_IMAG_DSCR:
5755
Err = "Image descriptor is still active";
5856
break;
59-
case E_GIF_ERR_NO_COLOR_MAP:
57+
case E_GIF_ERR_NO_COLOR_MAP:
6058
Err = "Neither global nor local color map";
6159
break;
62-
case E_GIF_ERR_DATA_TOO_BIG:
60+
case E_GIF_ERR_DATA_TOO_BIG:
6361
Err = "Number of pixels bigger than width * height";
6462
break;
65-
case E_GIF_ERR_NOT_ENOUGH_MEM:
63+
case E_GIF_ERR_NOT_ENOUGH_MEM:
6664
Err = "Failed to allocate required memory";
6765
break;
68-
case E_GIF_ERR_DISK_IS_FULL:
66+
case E_GIF_ERR_DISK_IS_FULL:
6967
Err = "Write failed (disk full?)";
7068
break;
71-
case E_GIF_ERR_CLOSE_FAILED:
69+
case E_GIF_ERR_CLOSE_FAILED:
7270
Err = "Failed to close given file";
7371
break;
74-
case E_GIF_ERR_NOT_WRITEABLE:
72+
case E_GIF_ERR_NOT_WRITEABLE:
7573
Err = "Given file was not opened for write";
7674
break;
77-
case D_GIF_ERR_OPEN_FAILED:
75+
case D_GIF_ERR_OPEN_FAILED:
7876
Err = "Failed to open given file";
7977
break;
80-
case D_GIF_ERR_READ_FAILED:
78+
case D_GIF_ERR_READ_FAILED:
8179
Err = "Failed to read from given file";
8280
break;
83-
case D_GIF_ERR_NOT_GIF_FILE:
81+
case D_GIF_ERR_NOT_GIF_FILE:
8482
Err = "Data is not in GIF format";
8583
break;
86-
case D_GIF_ERR_NO_SCRN_DSCR:
84+
case D_GIF_ERR_NO_SCRN_DSCR:
8785
Err = "No screen descriptor detected";
8886
break;
89-
case D_GIF_ERR_NO_IMAG_DSCR:
87+
case D_GIF_ERR_NO_IMAG_DSCR:
9088
Err = "No Image Descriptor detected";
9189
break;
92-
case D_GIF_ERR_NO_COLOR_MAP:
90+
case D_GIF_ERR_NO_COLOR_MAP:
9391
Err = "Neither global nor local color map";
9492
break;
95-
case D_GIF_ERR_WRONG_RECORD:
93+
case D_GIF_ERR_WRONG_RECORD:
9694
Err = "Wrong record type detected";
9795
break;
98-
case D_GIF_ERR_DATA_TOO_BIG:
96+
case D_GIF_ERR_DATA_TOO_BIG:
9997
Err = "Number of pixels bigger than width * height";
10098
break;
101-
case D_GIF_ERR_NOT_ENOUGH_MEM:
99+
case D_GIF_ERR_NOT_ENOUGH_MEM:
102100
Err = "Failed to allocate required memory";
103101
break;
104-
case D_GIF_ERR_CLOSE_FAILED:
102+
case D_GIF_ERR_CLOSE_FAILED:
105103
Err = "Failed to close given file";
106104
break;
107-
case D_GIF_ERR_NOT_READABLE:
105+
case D_GIF_ERR_NOT_READABLE:
108106
Err = "Given file was not opened for read";
109107
break;
110-
case D_GIF_ERR_IMAGE_DEFECT:
108+
case D_GIF_ERR_IMAGE_DEFECT:
111109
Err = "Image is defective, decoding aborted";
112110
break;
113-
case D_GIF_ERR_EOF_TOO_SOON:
111+
case D_GIF_ERR_EOF_TOO_SOON:
114112
Err = "Image EOF detected before image complete";
115113
break;
116-
default:
114+
default:
117115
Err = NULL;
118116
break;
119117
}

‎src/java.desktop/share/native/libsplashscreen/giflib/gif_hash.h

+11-13
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,25 @@ SPDX-License-Identifier: MIT
3333
#ifndef _GIF_HASH_H_
3434
#define _GIF_HASH_H_
3535

36-
/** Begin JDK modifications to support building on Windows **/
3736
#ifndef _WIN32
3837
#include <unistd.h>
39-
#endif
40-
/** End JDK modifications to support building on Windows **/
38+
#endif /* _WIN32 */
4139
#include <stdint.h>
4240

43-
#define HT_SIZE 8192 /* 12bits = 4096 or twice as big! */
44-
#define HT_KEY_MASK 0x1FFF /* 13bits keys */
45-
#define HT_KEY_NUM_BITS 13 /* 13bits keys */
46-
#define HT_MAX_KEY 8191 /* 13bits - 1, maximal code possible */
47-
#define HT_MAX_CODE 4095 /* Biggest code possible in 12 bits. */
41+
#define HT_SIZE 8192 /* 12bits = 4096 or twice as big! */
42+
#define HT_KEY_MASK 0x1FFF /* 13bits keys */
43+
#define HT_KEY_NUM_BITS 13 /* 13bits keys */
44+
#define HT_MAX_KEY 8191 /* 13bits - 1, maximal code possible */
45+
#define HT_MAX_CODE 4095 /* Biggest code possible in 12 bits. */
4846

4947
/* The 32 bits of the long are divided into two parts for the key & code: */
5048
/* 1. The code is 12 bits as our compression algorithm is limited to 12bits */
51-
/* 2. The key is 12 bits Prefix code + 8 bit new char or 20 bits. */
49+
/* 2. The key is 12 bits Prefix code + 8 bit new char or 20 bits. */
5250
/* The key is the upper 20 bits. The code is the lower 12. */
53-
#define HT_GET_KEY(l) (l >> 12)
54-
#define HT_GET_CODE(l) (l & 0x0FFF)
55-
#define HT_PUT_KEY(l) (l << 12)
56-
#define HT_PUT_CODE(l) (l & 0x0FFF)
51+
#define HT_GET_KEY(l) (l >> 12)
52+
#define HT_GET_CODE(l) (l & 0x0FFF)
53+
#define HT_PUT_KEY(l) (l << 12)
54+
#define HT_PUT_CODE(l) (l & 0x0FFF)
5755

5856
typedef struct GifHashTableType {
5957
uint32_t HTable[HT_SIZE];

‎src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h

+97-116
Large diffs are not rendered by default.

‎src/java.desktop/share/native/libsplashscreen/giflib/gif_lib_private.h

+36-34
Original file line numberDiff line numberDiff line change
@@ -33,52 +33,54 @@ SPDX-License-Identifier: MIT
3333
#ifndef _GIF_LIB_PRIVATE_H
3434
#define _GIF_LIB_PRIVATE_H
3535

36-
#include "gif_lib.h"
3736
#include "gif_hash.h"
37+
#include "gif_lib.h"
3838

3939
#ifndef SIZE_MAX
40-
#define SIZE_MAX UINTPTR_MAX
40+
#define SIZE_MAX UINTPTR_MAX
4141
#endif
4242

43-
#define EXTENSION_INTRODUCER 0x21
44-
#define DESCRIPTOR_INTRODUCER 0x2c
45-
#define TERMINATOR_INTRODUCER 0x3b
43+
#define EXTENSION_INTRODUCER 0x21
44+
#define DESCRIPTOR_INTRODUCER 0x2c
45+
#define TERMINATOR_INTRODUCER 0x3b
4646

47-
#define LZ_MAX_CODE 4095 /* Biggest code possible in 12 bits. */
48-
#define LZ_BITS 12
47+
#define LZ_MAX_CODE 4095 /* Biggest code possible in 12 bits. */
48+
#define LZ_BITS 12
4949

50-
#define FLUSH_OUTPUT 4096 /* Impossible code, to signal flush. */
51-
#define FIRST_CODE 4097 /* Impossible code, to signal first. */
52-
#define NO_SUCH_CODE 4098 /* Impossible code, to signal empty. */
50+
#define FLUSH_OUTPUT 4096 /* Impossible code, to signal flush. */
51+
#define FIRST_CODE 4097 /* Impossible code, to signal first. */
52+
#define NO_SUCH_CODE 4098 /* Impossible code, to signal empty. */
5353

54-
#define FILE_STATE_WRITE 0x01
55-
#define FILE_STATE_SCREEN 0x02
56-
#define FILE_STATE_IMAGE 0x04
57-
#define FILE_STATE_READ 0x08
54+
#define FILE_STATE_WRITE 0x01
55+
#define FILE_STATE_SCREEN 0x02
56+
#define FILE_STATE_IMAGE 0x04
57+
#define FILE_STATE_READ 0x08
5858

59-
#define IS_READABLE(Private) (Private->FileState & FILE_STATE_READ)
60-
#define IS_WRITEABLE(Private) (Private->FileState & FILE_STATE_WRITE)
59+
#define IS_READABLE(Private) (Private->FileState & FILE_STATE_READ)
60+
#define IS_WRITEABLE(Private) (Private->FileState & FILE_STATE_WRITE)
6161

6262
typedef struct GifFilePrivateType {
63-
GifWord FileState, FileHandle, /* Where all this data goes to! */
64-
BitsPerPixel, /* Bits per pixel (Codes uses at least this + 1). */
65-
ClearCode, /* The CLEAR LZ code. */
66-
EOFCode, /* The EOF LZ code. */
67-
RunningCode, /* The next code algorithm can generate. */
68-
RunningBits, /* The number of bits required to represent RunningCode. */
69-
MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits. */
70-
LastCode, /* The code before the current code. */
71-
CrntCode, /* Current algorithm code. */
72-
StackPtr, /* For character stack (see below). */
73-
CrntShiftState; /* Number of bits in CrntShiftDWord. */
74-
unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */
75-
unsigned long PixelCount; /* Number of pixels in image. */
76-
FILE *File; /* File as stream. */
77-
InputFunc Read; /* function to read gif input (TVT) */
78-
OutputFunc Write; /* function to write gif output (MRB) */
79-
GifByteType Buf[256]; /* Compressed input is buffered here. */
63+
GifWord FileState, FileHandle, /* Where all this data goes to! */
64+
BitsPerPixel, /* Bits per pixel (Codes uses at least this + 1). */
65+
ClearCode, /* The CLEAR LZ code. */
66+
EOFCode, /* The EOF LZ code. */
67+
RunningCode, /* The next code algorithm can generate. */
68+
RunningBits, /* The number of bits required to represent
69+
RunningCode. */
70+
MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits.
71+
*/
72+
LastCode, /* The code before the current code. */
73+
CrntCode, /* Current algorithm code. */
74+
StackPtr, /* For character stack (see below). */
75+
CrntShiftState; /* Number of bits in CrntShiftDWord. */
76+
unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */
77+
unsigned long PixelCount; /* Number of pixels in image. */
78+
FILE *File; /* File as stream. */
79+
InputFunc Read; /* function to read gif input (TVT) */
80+
OutputFunc Write; /* function to write gif output (MRB) */
81+
GifByteType Buf[256]; /* Compressed input is buffered here. */
8082
GifByteType Stack[LZ_MAX_CODE]; /* Decoded pixels are stacked here. */
81-
GifByteType Suffix[LZ_MAX_CODE + 1]; /* So we can trace the codes. */
83+
GifByteType Suffix[LZ_MAX_CODE + 1]; /* So we can trace the codes. */
8284
GifPrefixType Prefix[LZ_MAX_CODE + 1];
8385
GifHashTableType *HashTable;
8486
bool gif89;

‎src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c

+130-125
Large diffs are not rendered by default.

‎src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,22 @@
2828
* SPDX-License-Identifier: MIT
2929
*/
3030

31-
#include <sys/types.h>
3231
#include <errno.h>
3332
#include <stdint.h>
3433
#include <stdlib.h>
34+
#include <sys/types.h>
3535

3636
#ifndef SIZE_MAX
37-
#define SIZE_MAX UINTPTR_MAX
37+
#define SIZE_MAX UINTPTR_MAX
3838
#endif
3939

4040
/*
4141
* This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
4242
* if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW
4343
*/
44-
#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
44+
#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
4545

46-
void *
47-
openbsd_reallocarray(void *optr, size_t nmemb, size_t size)
48-
{
46+
void *openbsd_reallocarray(void *optr, size_t nmemb, size_t size) {
4947
if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
5048
nmemb > 0 && SIZE_MAX / nmemb < size) {
5149
errno = ENOMEM;
@@ -93,7 +91,8 @@ openbsd_reallocarray(void *optr, size_t nmemb, size_t size)
9391
* fuzzing on one platform may not detect zero-size allocation
9492
* problems on other platforms.
9593
*/
96-
if (size == 0 || nmemb == 0)
94+
if (size == 0 || nmemb == 0) {
9795
return NULL;
96+
}
9897
return realloc(optr, size * nmemb);
9998
}

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Jun 5, 2024

@openjdk-notifier[bot]
Please sign in to comment.