| Previous | Next |
| WINCODEC_ERR_COMPONENTINITIALIZEFAILURE | WINCODEC_ERR_DUPLICATEMETADATAPRESENT |
WINCODEC_ERR_INSUFFICIENTBUFFER
Buffer capacity must match the WIC method’s byte contract
WINCODEC_ERR_INSUFFICIENTBUFFER means the caller-provided storage cannot contain the requested result. For pixel copying, capacity depends on the source rectangle, pixel format, stride, and total buffer size; confusing pixels with bytes or using an unaligned row size commonly produces an undersized allocation. Other WIC APIs use count-then-fill patterns and report the required element or byte count separately.
The diagnostic should retain every size used in the call. Multiplication overflow is especially important for large or untrusted images: a wrapped height × stride can allocate a small buffer even though each individual dimension looked valid. Increasing an arbitrary constant hides the calculation error and can still fail for a different image.
Size calculation checks
- Record width, height, bits per pixel, source rectangle, stride, and buffer byte count.
- Validate arithmetic for overflow before allocating or passing the size to WIC.
- Follow two-call enumeration patterns when an API reports the required count.
- Keep decoder output format changes synchronized with the stride calculation.
References
- Microsoft: IWICBitmapSource::CopyPixels
- Microsoft: WIC bitmap sources and pixel formats
- Microsoft: WIC interface contracts
Looking for a different code? Search another status or error code.