Bug 27454

Summary: Crash when trying to display a non-existent ImageIcon file
Product: classpath Reporter: Yvan Norsa <yvan.norsa>
Component: swingAssignee: Roman Kennke <roman>
Severity: normal CC: bug-classpath
Priority: P3    
Version: unspecified   
Target Milestone: 0.91   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:
Attachments: TestCase demonstrating the JVM crash
Small patch fixing the problem

Description Yvan Norsa 2006-05-06 10:20:52 UTC
If you create an ImageIcon with a file which doesn't exist, and if you try to draw the resulting Image using drawImage with the x, y, width and height parameters (if you omit width and height, the bug doesn't occur), then the JVM crashes
(tested with jamvm and cacao).
Comment 1 Yvan Norsa 2006-05-06 10:22:01 UTC
Created attachment 11387 [details]
TestCase demonstrating the JVM crash
Comment 2 Yvan Norsa 2006-05-06 11:43:31 UTC
Created attachment 11388 [details]
Small patch fixing the problem

I traced the code, and the problem comes from trying to draw the "error image" (that is, a blank GtkImage) (so the bug is probably platform-dependent).
I noticed that when not passing width and height to drawImage(), the bug doesn't occur. That is because in drawPixelsScaled, the width and height parameters are checked, and if they are <= 0, the function returns.
So my fix is to check also the image size, and to return if it is lower or equal than 0.
Comment 3 Sven de Marothy 2006-05-06 21:12:00 UTC