Permalink
Browse files

lint

  • Loading branch information...
1 parent 6cee92a commit 7c0e671ffc83aa4789aa0aa64e9231b09281a685 @mpgerlek mpgerlek committed May 15, 2012
@@ -61,7 +61,7 @@ class PDAL_DLL VariableLengthRecord
boost::uint16_t recordId,
std::string description,
const boost::uint8_t* bytes,
- std::size_t len);
+ boost::uint16_t len);
VariableLengthRecord(const VariableLengthRecord&);
~VariableLengthRecord();
@@ -66,7 +66,7 @@ VariableLengthRecord::VariableLengthRecord(boost::uint16_t reserved,
boost::uint16_t recordId,
std::string description,
const boost::uint8_t* bytes,
- std::size_t length)
+ boost::uint16_t length)
: m_reserved(0xAABB)
, m_userId(userId)
, m_recordId(recordId)
@@ -489,7 +489,7 @@ void VariableLengthRecord::setVLRsFromSRS(const SpatialReference& srs, std::vect
throw std::runtime_error(oss.str());
}
- VariableLengthRecord wkt_record(0, s_wktUserId, s_wktRecordId, s_wktDescription, wkt_bytes, len);
+ VariableLengthRecord wkt_record(0, s_wktUserId, s_wktRecordId, s_wktDescription, wkt_bytes, (boost::uint16_t)len);
vlrs.push_back(wkt_record);
}
@@ -157,7 +157,17 @@ VariableLengthRecord ZipPoint::ConstructVLR() const
int num;
m_zip->pack(data, num);
- VariableLengthRecord vlr(0xAABB, laszip_userid, laszip_recordid, laszip_description, data, num);
+ if (num > std::numeric_limits<boost::uint16_t>::max())
+ {
+ std::ostringstream oss;
+ std::vector<boost::uint8_t>::size_type overrun = num - static_cast<std::vector<boost::uint8_t>::size_type>(std::numeric_limits<boost::uint16_t>::max());
+ oss << "The size of the wkt, " << num << ", is " << overrun
+ << " bytes too large to fit inside the maximum size of a VLR which is "
+ << std::numeric_limits<boost::uint16_t>::max() << " bytes.";
+ throw std::runtime_error(oss.str());
+ }
+
+ VariableLengthRecord vlr(0xAABB, laszip_userid, laszip_recordid, laszip_description, data, (boost::uint16_t)num);
return vlr;
}

0 comments on commit 7c0e671

Please sign in to comment.