Skip to main content

MAX_ELEMENT_DEPTH

Constant MAX_ELEMENT_DEPTH 

Source
pub const MAX_ELEMENT_DEPTH: usize = 32;
Expand description

The deepest element nesting parse accepts. Real files nest five deep (<engine-database>, <engine-list>, <engine>, <data>, <eng-data>).

The XML parser descends into nested elements recursively, and a stack overflow aborts the process rather than panicking, so a hostile or corrupt file must be refused before parsing. Measured on macOS aarch64: a debug build uses about 15 KB of stack per level (48 levels fit in 1 MB, the wasm32 default, and 64 don’t), a release build under 1 KB.