8210866: Improve JPEG processing
authorprr
Mon, 08 Oct 2018 12:53:53 -0700
changeset 53331 b9149d907610
parent 53330 e8bae92beee3
child 53332 ab474ef0a0ac
8210866: Improve JPEG processing Reviewed-by: serb, psadhukhan, rhalade
src/java.desktop/share/native/libjavajpeg/jmemmgr.c
--- a/src/java.desktop/share/native/libjavajpeg/jmemmgr.c	Mon Oct 08 12:55:04 2018 +0800
+++ b/src/java.desktop/share/native/libjavajpeg/jmemmgr.c	Mon Oct 08 12:53:53 2018 -0700
@@ -406,6 +406,9 @@
   JDIMENSION rowsperchunk, currow, i;
   long ltemp;
 
+  if (samplesperrow == 0) {
+    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
+  }
   /* Calculate max # of rows allowed in one allocation chunk */
   ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) /
           ((long) samplesperrow * SIZEOF(JSAMPLE));
@@ -454,6 +457,10 @@
   JDIMENSION rowsperchunk, currow, i;
   long ltemp;
 
+  if (blocksperrow == 0) {
+    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
+  }
+
   /* Calculate max # of rows allowed in one allocation chunk */
   ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) /
           ((long) blocksperrow * SIZEOF(JBLOCK));