Bug 22999 - Null check after dereference in java.awt.image.ConvolveOp
Summary: Null check after dereference in java.awt.image.ConvolveOp
Status: RESOLVED FIXED
Alias: None
Product: classpath
Classification: Unclassified
Component: awt (show other bugs)
Version: unspecified
: P3 normal
Target Milestone: 0.18
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-18 21:30 UTC by from-classpath
Modified: 2005-09-06 12:45 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-07-26 21:13:10


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description from-classpath 2005-06-18 21:30:10 UTC
In classpath-0.15:

In class java.awt.image.ConvolveOp, at line 191, is
the following code:

  public WritableRaster filter(Raster src, WritableRaster dest) {
    if (src.numBands != dest.numBands)
      throw new ImagingOpException(null);
    if (src == dest)
      throw new IllegalArgumentException();
    if (src.getWidth() < kernel.getWidth() ||
        src.getHeight() < kernel.getHeight())
      throw new ImagingOpException(null);
    
    if (dest == null)
      dest = createCompatibleDestRaster(src);

The check "dest == null" cannot be true because dest was
dereferenced on the first line of the method.
That check should probably be modified so that it does not
happen if dest is null.

Found by FindBugs, http://findbugs.sourceforge.net
Comment 1 from-classpath 2005-06-18 21:42:36 UTC
I realized that the last sentence of my explanation was
confusing.  What I meant to say is:

The earlier check "src.numBands != dest.numBands" should be
modified so it is bypassed if dest is null.
Comment 2 Andrew Pinski 2005-07-26 21:13:10 UTC
Confirmed.
Comment 3 Tom Tromey 2005-08-11 18:29:57 UTC
I checked in a fix.
Comment 4 cvs-commit@developer.classpath.org 2005-08-11 19:28:58 UTC
Subject: Bug 22999

CVSROOT:	/cvsroot/classpath
Module name:	classpath
Branch: 	
Changes by:	Tom Tromey <tromey@savannah.gnu.org>	05/08/11 18:29:23

Modified files:
	.              : ChangeLog 
	java/awt/image : ConvolveOp.java 

Log message:
	* java/awt/image/ConvolveOp.java (filter): Defer numBands check
	until after null check.  PR classpath/22999.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.4387&tr2=1.4388&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/java/awt/image/ConvolveOp.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text