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
In internal/api/files.go:444-458 (also reachable via internal/api/gemini_files.go:466), multipartStreamMIME decodes the first frame of uploaded GIFs and draws it onto an RGBA canvas sized by config.Width x config.Height:
16 GiB OOM crash from a ~35-byte GIF: Uploading a valid GIF89a with Logical Screen Descriptor 65535 x 65535 and a 1 x 1 image descriptor to POST /v1/files or POST /upload/v1beta/files passes gif.Decode (which only allocates the 1 x 1 frame), then gifJPEG calls image.NewRGBA(image.Rect(0, 0, 65535, 65535)), attempting a 17.18 GB allocation (65535 * 65535 * 4) and crashing the Go process with OOM.
Silent 0-byte JPEG upload: A valid 0 x 0 GIF passes decodeGIFFrame, creates an empty canvas, fails jpeg.Encode (invalid image size: 0x0, error discarded with _ =), and returns 0 bytes labeled image/jpeg.
Suggested Fix
Validate config.Width > 0 && config.Height > 0 and cap int64(config.Width)*int64(config.Height) (e.g., <= 64_000_000) in gifJPEG, and check the jpeg.Encode error before replacing data and mediaType.
Fixed in v0.3.14, GIFs with zero dimensions or canvas over 64M pixels are left untouched in both file upload and inline normalization instead of allocating a huge RGBA canvas.
Activity
Mag1cFall commentedon Nov 22, 2026
Fixed in v0.3.14, GIFs with zero dimensions or canvas over 64M pixels are left untouched in both file upload and inline normalization instead of allocating a huge RGBA canvas.