When reallocating a vector buffer, it assumes that the first half of the new buffer was clean or populated from the previous and only zeros out the second half. This is not the case if the vector has released the buffer and the current capacity is 0 (empty). If the new buffer has values set, then they will cause bogus values when used in the vector.
I came across this when looking into
SPARK-23030, due to the comment here https://github.com/apache/spark/pull/21312#issuecomment-389035697