Its possible to get caught in an infinite loop in the DecodeFactory::Decode function when readings invalid data. If the header.length value is 0 then the loop will never end.
One possible solution is to validate the length value in the Header::Decode function.