Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4919031

LookOp.filter() crashes VM when attempt to filter CMYK jpeg.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 1.4.0, 5.0
    • client-libs
    • None
    • 2d
    • x86, sparc
    • solaris_8, windows_xp

      Start the program below with the attached .jpg file as input and any name as output. The VM will crash. The log of crash attached. Problem reproducible on
      JDK 1.4.0, 1.4.2 and current sources.

      import javax.imageio.*;
      import java.awt.*;
      import java.awt.image.*;
      import java.awt.color.ColorSpace;
      import java.io.*;
      import java.util.*;

      public class ImageInvertor
      {
          public static void main( String[] args )
              throws IOException
          {
              if ( args.length != 2 ) {
                  System.out.println( "Usage is: ImageInvertor <inFile.jpg> <outFile.jpg>" );
                  return;
              }
              long startTime = System.currentTimeMillis();

              String inFileName = args[0];
              System.out.println(inFileName);
              String outFileName = args[1];

              // read
              BufferedImage img = ImageIO.read( new BufferedInputStream( new FileInputStream( inFileName ) ) );
              if ( img == null )
                  throw new IOException( "File format is unknown" );

              BufferedImage oimg =
                  new BufferedImage( img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB );

              byte invert[] = new byte[256];
              for (int j = 0; j < 256 ; j++) {
                  invert[j] = (byte) (256-j);
              }
              LookupOp lop = new LookupOp( new ByteLookupTable( 0, invert ), null );

              lop.filter( img, oimg );


              // write
              OutputStream out = new BufferedOutputStream( new FileOutputStream( outFileName ) );
              try {
                  ImageIO.write( oimg, "JPEG", out );
              }
              finally {
                  out.close();
              }

              System.out.println( "Time consumed: " + ( System.currentTimeMillis() - startTime ) + "ms" );
         }
      }

            Unassigned Unassigned
            kizune Alexander Zuev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: