defaultMaxOutputBytes top-level constant

int const defaultMaxOutputBytes

The default upper bound, in bytes, on the buffer ZstdSimple.decompress will allocate for a frame's declared decompressed size.

decompress reads the declared content size from the Zstd frame header and allocates a buffer of that size before running the actual decompression. That declared size is untrusted input — it comes from the frame being decompressed, not from anything the caller controls — so a tiny, cheaply-produced frame can declare an enormous content size and force a huge allocation before decompression has verified anything. This constant bounds that allocation.

64 MiB (64 * 1024 * 1024) is 64x KMDB's kMaxDecodedValueBytes (1 MiB) decoded-value ceiling, so it does not fire in normal KMDB use, while still capping the worst case a single call can allocate.

There is no unbounded/opt-out mode: a caller that needs to decompress something larger than the default passes a larger explicit maxOutputBytes value (e.g. 1 << 40) to decompress.

Peak transient memory for a call that stays under the cap is a multiple of maxOutputBytes, not the cap itself: on native it is approximately 2x (the native buffer plus the copy into a Dart-managed Uint8List); on web it is approximately 3x (the WASM heap allocation, plus sublist, plus the Uint8List.fromList copy) — and the WASM heap grows to fit but never shrinks back down afterwards.

Implementation

const int defaultMaxOutputBytes = 64 * 1024 * 1024;