--- old/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java 2018-01-08 15:20:53.878312071 +0530 +++ new/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java 2018-01-08 15:20:53.474312071 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, 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 @@ -1048,7 +1048,8 @@ int bytesPerPixel = (bitDepth == 16) ? 2 : 1; bytesPerPixel *= inputBands; - int bytesPerRow = (inputBands*passWidth*bitDepth + 7)/8; + int bitsPerRow = Math.multiplyExact((inputBands * bitDepth), passWidth); + int bytesPerRow = (bitsPerRow + 7) / 8; int eltsPerRow = (bitDepth == 16) ? bytesPerRow/2 : bytesPerRow; // If no pixels need updating, just skip the input data