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

zip DeflaterOutputStream/InflaterInputStream ctors don't check for null

    XMLWordPrintable

Details

    • jar
    • 1.2fcs
    • sparc
    • solaris_2.5
    • Verified

    Description



      Name: sdC67446 Date: 02/12/98


      Constructor java.util.zip.DeflaterOutputStream(OutputStream os, Deflater def)
      doesn't check parameter "def" for null. Thus calling the write method later
      causes undocumented NullPointerException.

      The similar bug is present in InflaterInputStream constructor as well.

      --------------------------------------------------
      Here is the test demonstrating the bug:
      -----------------Test.java------------------------
      import java.util.zip.*;
      import java.io.*;

      public class Test {
        
        public static void main(String[] args) {

          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          Deflater def = null;
          
          DeflaterOutputStream defOS = new DeflaterOutputStream(bos, def);
          System.out.println("Constructed!");
          
          try {
            defOS.write(100);
          } catch ( NullPointerException e ) {
            System.out.println("NullPointerException thrown while writing!");
          } catch ( IOException e ) {
            System.out.println(e);
          }
        }
      }
      ---------Output from the test---------------------
      Constructed!
      NullPointerException thrown while writing!
      --------------------------------------------------

      ======================================================================

      Attachments

        Activity

          People

            dconnellsunw David Connelly (Inactive)
            sdmitriesunw Sergei Dmitriev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: