Fix a memory corruption bug in Metadata marshaling.

The code in question was trying to double the length of an array but
accidentally threw away the new larger array (and copied too few bytes
to the newly allocated array, in any case).