Skip to content

Commit

Permalink
PlatformImage: If an image from stream is null, don't throw a NPE
Browse files Browse the repository at this point in the history
House M.D tries to load some nonexistent images like ekg_heart.png
and doesn't handle the received NullPointerException properly, so
we cannot throw an exception in these cases.
  • Loading branch information
AShiningRay committed Jan 1, 2025
1 parent b245a22 commit 8b13fa4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/org/recompile/mobile/PlatformImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ public PlatformImage(String name)

InputStream stream = Mobile.getPlatform().loader.getMIDletResourceAsStream(name);

if(stream==null) { throw new NullPointerException("Can't load image from resource, as the returned image is null."); }
if(stream==null)
{
// We should really throw an exception here, but House M.D is one game that explicitly tries to load null images without proper exception handling
//throw new NullPointerException("Can't load image from resource, as the returned image is null.");
Mobile.log(Mobile.LOG_WARNING, PlatformImage.class.getPackage().getName() + "." + PlatformImage.class.getSimpleName() + ": " + "Image From Resource Name failed, is NULL. Might not render properly unless the jar expects it");
}
else
{
try { temp = ImageIO.read(stream); }
Expand Down

0 comments on commit 8b13fa4

Please sign in to comment.