GeospatialPython / pyshp

This library reads and writes ESRI Shapefiles in pure Python.
MIT License
1.1k stars 259 forks source link

Fix Reader.__shape(self) for PointZ without M values #120

Closed ShinNoNoir closed 6 years ago

ShinNoNoir commented 6 years ago

M values are optional for the PointZ shape type. If a PointZ shapefile did not contain M values, the old code would incorrectly fetch bytes from the next record and store it in the m field. For the last record, the code would crash since f.read(8) would return an empty string.

In order to fix this, this commit checks whether there are any bytes left (f.tell() < next1) when the shape type is PointZ (11).

karimbahgat commented 6 years ago

This seems like a pretty serious bug, probably not enough people use m or z values is why it hasn't been noticed until now. So thanks 👍