Bug 27454 - Crash when trying to display a non-existent ImageIcon file
Summary: Crash when trying to display a non-existent ImageIcon file
Alias: None
Product: classpath
Classification: Unclassified
Component: swing (show other bugs)
Version: unspecified
: P3 normal
Target Milestone: 0.91
Assignee: Roman Kennke
Depends on:
Reported: 2006-05-06 10:20 UTC by Yvan Norsa
Modified: 2006-05-07 20:29 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:

TestCase demonstrating the JVM crash (271 bytes, text/x-java)
2006-05-06 10:22 UTC, Yvan Norsa
Small patch fixing the problem (433 bytes, patch)
2006-05-06 11:43 UTC, Yvan Norsa
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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