[Liblas-commits] hg-main-tree: handle 64-bit errors
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Mar 25 14:25:13 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/00c1e0355271
changeset: 463:00c1e0355271
user: Michael P. Gerlek <mpg at flaxen.com>
date: Fri Mar 25 11:25:06 2011 -0700
description:
handle 64-bit errors
diffstat:
src/drivers/liblas/Iterator.cpp | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diffs (27 lines):
diff -r b86cf9014e60 -r 00c1e0355271 src/drivers/liblas/Iterator.cpp
--- a/src/drivers/liblas/Iterator.cpp Fri Mar 25 11:10:15 2011 -0700
+++ b/src/drivers/liblas/Iterator.cpp Fri Mar 25 11:25:06 2011 -0700
@@ -211,10 +211,20 @@
boost::uint64_t SequentialIterator::skipImpl(boost::uint64_t count)
{
- boost::uint64_t newPos = getIndex() + count;
+ const boost::uint64_t newPos64 = getIndex() + count;
- size_t newPosX = (size_t)newPos;
- getExternalReader().Seek(newPosX);
+ // The liblas reader's seek() call only supports size_t, so we might
+ // not be able to satisfy this request...
+
+ if (newPos64 > std::numeric_limits<size_t>::max())
+ {
+ throw libpc_error("cannot support seek offsets greater than 32-bits");
+ }
+
+ // safe cast, since we just handled the overflow case
+ size_t newPos = static_cast<size_t>(newPos64);
+
+ getExternalReader().Seek(newPos);
return count;
}
More information about the Liblas-commits
mailing list