--- old/src/java.desktop/share/native/libjavajpeg/jchuff.c 2018-05-31 14:00:16.844859575 +0100 +++ new/src/java.desktop/share/native/libjavajpeg/jchuff.c 2018-05-31 14:00:16.714859575 +0100 @@ -805,8 +805,11 @@ for (i = MAX_CLEN; i > 16; i--) { while (bits[i] > 0) { j = i - 2; /* find length of new prefix to be used */ - while (bits[j] == 0) - j--; + while (bits[j] == 0) { + if (j == 0) + ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW); + j--; + } bits[i] -= 2; /* remove two symbols */ bits[i-1]++; /* one goes in this length */