paulmach / orb

Types and utilities for working with 2d geometry in Golang
MIT License
910 stars 103 forks source link

encoding/wkb: Only limit allocation not reading #27

Closed paulmach closed 5 years ago

paulmach commented 5 years ago

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....