x/image/draw: panic resizing image.Uniform #60412
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I have code that downloads an image and tries to rescale it. In the event that the download failed, it falls back to a simple
image.Uniform
and uses that instead. However, this approach actually panics during the rescale in a surprising way:https://go.dev/play/p/01WIzG_E0nb
What did you expect to see?
I expected rescaling an
image.Uniform
to be trivial since it doesn't actually need to do any work.What did you see instead?
Because
image.Uniform.Bounds()
returns an effectively-infinite size, using the bounds of the image as input to the rescale operation makes the rescale try to allocate a buffer larger than available memory.I understand that I can special-case this in my logic, but it seems desirable for this not to crash in general when an
image.Uniform
happens to be the input to the rescale operation. Applications like mine may be pulling these images from a variety of sources, and needing this special case is surprising.I'd be happy to submit a patch that handles this as a special case in the rescale if that's the desired approach.
CC @dominikh @nigeltao @pedroleiterocha @JackMordaunt
The text was updated successfully, but these errors were encountered: