ZoeyR / flif.rs

flif decoder written in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fuzzing: huge memory usage take 2

newpavlov opened this issue · comments

Input:

FLIF11F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00FLIF\x00\x00L\xc5XifI\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00FLIF\x00\x00\x00\x00\x00\x00\x00

Looks to be due to a highly imbalanced maniac tree. Unfortunately the standard method of binary tree storage is terrible for this use case. It could be improved by just storing child indicies in the nodes and just placing newly created children at the end. The interesting side-effect of that is that certain cases will be highly cache-friendly.