lengths should be size32_t.  Tricky for you to know since there are several old counter-examples in this file.