shape.input - add stream state check and calculate position limit

This commit is contained in:
artemp 2015-10-21 16:33:12 +01:00
parent 9f439d1e2e
commit c3ccff4f02
2 changed files with 7 additions and 1 deletions

View file

@ -71,7 +71,8 @@ feature_ptr shape_featureset<filterT>::next()
return feature_ptr(); return feature_ptr();
} }
while (shape_.shx().pos() < 2 * shx_file_length_) std::streampos position_limit = 2 * shx_file_length_ - 2 * sizeof(int);
while (shape_.shx().is_good() && shape_.shx().pos() <= position_limit)
{ {
int offset = shape_.shx().read_xdr_integer(); int offset = shape_.shx().read_xdr_integer();
int record_length = shape_.shx().read_xdr_integer(); int record_length = shape_.shx().read_xdr_integer();

View file

@ -259,6 +259,11 @@ public:
{ {
return file_.eof(); return file_.eof();
} }
inline bool is_good()
{
return file_.good();
}
}; };
#endif // SHAPEFILE_HPP #endif // SHAPEFILE_HPP