Intention is to preallocate the memory needed by the item. This is great for wellformed input. However, bad data could have a big number as the first few bytes causing a large allocation to be requested. So we want to max out this preallocation to prevent that.
In the malformed case you'd probably get a io.EOF type error.
The original code limited the allocation and the number read. Good, but very big, data was not read in completely. Ooops....
Fixes https://github.com/paulmach/orb/issues/26
Intention is to preallocate the memory needed by the item. This is great for wellformed input. However, bad data could have a big number as the first few bytes causing a large allocation to be requested. So we want to max out this preallocation to prevent that.
In the malformed case you'd probably get a io.EOF type error.
The original code limited the allocation and the number read. Good, but very big, data was not read in completely. Ooops....