Skip to content

Commit

Permalink
Improve failure mode when FNA3D fails to decode an image
Browse files Browse the repository at this point in the history
  • Loading branch information
kg authored and flibitijibibo committed Jan 30, 2024
1 parent 39ce6e0 commit 1a7fa53
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Graphics/Texture2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ public static Texture2D FromStream(GraphicsDevice graphicsDevice, Stream stream)
out height,
out len
);
if ((pixels == IntPtr.Zero) || (width <= 0) || (height <= 0))
throw new Exception("Decoding image failed!");

Texture2D result = new Texture2D(
graphicsDevice,
Expand Down Expand Up @@ -458,6 +460,8 @@ bool zoom
height,
zoom
);
if ((pixels == IntPtr.Zero) || (realWidth <= 0) || (realHeight <= 0))
throw new Exception("Decoding image failed!");

Texture2D result = new Texture2D(
graphicsDevice,
Expand Down

0 comments on commit 1a7fa53

Please sign in to comment.