Skip to content

Commit

Permalink
make sure to use 64bit math for calculating buffer position when read…
Browse files Browse the repository at this point in the history
…ing data
  • Loading branch information
hobu committed Oct 1, 2013
1 parent 5c43edd commit 13b11f2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/drivers/las/Reader.cpp
Expand Up @@ -198,12 +198,12 @@ boost::uint32_t Reader::processBuffer(PointBuffer& data,

const bool hasTime = Support::hasTime(pointFormat);
const bool hasColor = Support::hasColor(pointFormat);
boost::uint16_t pointByteCount = Support::getPointDataSize(pointFormat);
PointBufferByteSize pointByteCount = Support::getPointDataSize(pointFormat);


if (read_buffer.size() < (pointByteCount * numPoints))
{
boost::int64_t size = pointByteCount * numPoints64;
PointBufferByteSize size = pointByteCount * numPoints64;
read_buffer.resize(size);
}

Expand Down Expand Up @@ -253,7 +253,7 @@ boost::uint32_t Reader::processBuffer(PointBuffer& data,
bool bFirstPoint(true);
for (boost::uint32_t pointIndex=0; pointIndex<numPoints; pointIndex++)
{
boost::uint8_t* p = &(read_buffer.front()) + pointByteCount * pointIndex;
boost::uint8_t* p = &(read_buffer.front()) + static_cast<PointBufferByteSize>(pointByteCount) * static_cast<PointBufferByteSize>(pointIndex);

// always read the base fields
{
Expand Down Expand Up @@ -795,11 +795,11 @@ boost::uint64_t Reader::skipImpl(boost::uint64_t count)
}
else
{
boost::uint64_t delta = Support::getPointDataSize(m_reader.getLasHeader().getPointFormat());
PointBufferByteSize delta = Support::getPointDataSize(m_reader.getLasHeader().getPointFormat());
m_istream.seekg(delta * count, std::ios::cur);
}
#else
boost::uint64_t delta = Support::getPointDataSize(m_reader.getLasHeader().getPointFormat());
PointBufferByteSize delta = Support::getPointDataSize(m_reader.getLasHeader().getPointFormat());
m_istream.seekg(delta * count, std::ios::cur);
#endif
return count;
Expand Down Expand Up @@ -872,12 +872,12 @@ boost::uint64_t Reader::seekImpl(boost::uint64_t count)
}
else
{
boost::uint64_t delta = Support::getPointDataSize(m_reader.getLasHeader().getPointFormat());
PointBufferByteSize delta = Support::getPointDataSize(m_reader.getLasHeader().getPointFormat());
m_istream.seekg(m_reader.getLasHeader().GetDataOffset() + delta * count);
}
#else

boost::uint64_t delta = Support::getPointDataSize(m_reader.getLasHeader().getPointFormat());
PointBufferByteSize delta = Support::getPointDataSize(m_reader.getLasHeader().getPointFormat());
m_istream.seekg(m_reader.getLasHeader().GetDataOffset() + delta * count);

#endif
Expand Down

0 comments on commit 13b11f2

Please sign in to comment.