Fixes the following issues:
* Compound array elements subject to tail array optimization could be
decoded incorrectly, causing a decode failure.
* Invalid array lengths could be sent over the wire if a
longer-than-max array was encoded (though only the max number of
elements was sent).
* Lengths were not validated when decoding arrays of compound elements
using TAO, causing memory corruption if an invalid length was received.
* Union tags were not validated, causing undefined behavior if an
invalid tag was received.