8200052: libjavajpeg: Fix compile warning in jchuff.c
authorprr
Fri, 01 Jun 2018 09:16:36 -0700
changeset 50361 071f1fe0df5f
parent 50360 8fbbd19bf3a1
child 50362 86ac3ffaf991
8200052: libjavajpeg: Fix compile warning in jchuff.c Reviewed-by: prr Contributed-by: adam.farley@uk.ibm.com, thomas.stuefe@sap.com
src/java.desktop/share/native/libjavajpeg/jchuff.c
--- a/src/java.desktop/share/native/libjavajpeg/jchuff.c	Wed May 30 15:01:36 2018 +0200
+++ b/src/java.desktop/share/native/libjavajpeg/jchuff.c	Fri Jun 01 09:16:36 2018 -0700
@@ -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)
+      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 */