You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DivideByZeroException in PbmDecoderCore.ProcessUpscaling #3130
I have verified that I am running the latest version of ImageSharp
I have verified if the problem exist in both DEBUG and RELEASE mode
I have searched open and closed issues to ensure it has not already been reported
ImageSharp version
4.0.0 (commit: ff36e83) (not a regression, also present on 3.1.12)
Other ImageSharp packages and versions
N/A
Environment (Operating system, version and so on)
Ubuntu/Windows
.NET Framework version
.NET 10
Description
Loading a Netpbm image (PGM/PPM, ASCII or binary) with a maxval header field of 0 throws System.DivideByZeroException from PbmDecoderCore.ProcessUpscaling.
The standard puts this value to be less than 65536, and more than zero, so the input is malformed - and the decoder should surface it as InvalidImageContentException.
Any invalid value would trigger the same effect. In the current code maxPixelValue isn't validated after parsing, so 0 (either literally, or the parser's default when the field starts with a non-digit) ends up as the divisor in ProcessUpscaling.
Activity
JimBobSquarePants commentedon May 26, 2026
Thanks again @pawlos Much appreciated!