Changeset 4670


Ignore:
Timestamp:
12/03/08 17:30:58 (11 years ago)
Author:
melissa
Message:

If zlib data is truncated, return what can be decompressed instead of throwing an exception.

Location:
trunk/components/bio-formats/src/loci/formats
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/codec/ZlibCodec.java

    r4645 r4670  
    2424package loci.formats.codec; 
    2525 
    26 import java.io.IOException; 
     26import java.io.*; 
    2727import java.util.zip.Deflater; 
    2828import java.util.zip.InflaterInputStream; 
     
    6767    int r = 0; 
    6868    // read until eof reached 
    69     while ((r = i.read(buf, 0, buf.length)) > 0) bytes.add(buf, 0, r); 
     69    try { 
     70      while ((r = i.read(buf, 0, buf.length)) > 0) bytes.add(buf, 0, r); 
     71    } 
     72    catch (EOFException e) { } 
    7073    return bytes.toByteArray(); 
    7174  } 
  • trunk/components/bio-formats/src/loci/formats/in/ND2Reader.java

    r4655 r4670  
    146146      for (int row=0; row<h; row++) { 
    147147        int offset = (row + y) * effectiveX * pixel + x * pixel; 
    148         if (offset < t.length) { 
     148        if (offset + w * pixel <= t.length) { 
    149149          System.arraycopy(t, offset, buf, row * w * pixel, w * pixel); 
    150150        } 
Note: See TracChangeset for help on using the changeset viewer.