提交 25e739d4 编写于 作者: A Aaron Xiao 提交者: Jiangtao Hu

Localization: Check buffer size before using.

上级 3aba202d
...@@ -29,7 +29,7 @@ namespace localization { ...@@ -29,7 +29,7 @@ namespace localization {
namespace msf { namespace msf {
BaseMapNode::BaseMapNode(BaseMapMatrix* matrix, CompressionStrategy* strategy) BaseMapNode::BaseMapNode(BaseMapMatrix* matrix, CompressionStrategy* strategy)
: map_config_(NULL), map_matrix_(matrix), compression_strategy_(strategy) { : map_matrix_(matrix), compression_strategy_(strategy) {
is_changed_ = false; is_changed_ = false;
data_is_ready_ = false; data_is_ready_ = false;
is_reserved_ = false; is_reserved_ = false;
...@@ -223,8 +223,8 @@ unsigned int BaseMapNode::CreateBinary(FILE* file) const { ...@@ -223,8 +223,8 @@ unsigned int BaseMapNode::CreateBinary(FILE* file) const {
buf_size -= processed_size; buf_size -= processed_size;
binary_size += processed_size; binary_size += processed_size;
// Create body // Create body
memcpy(&buffer[buffer_bias], &body_buffer[0], body_buffer.size());
CHECK_GE(buf_size, body_buffer.size()); CHECK_GE(buf_size, body_buffer.size());
memcpy(&buffer[buffer_bias], &body_buffer[0], body_buffer.size());
binary_size += body_buffer.size(); binary_size += body_buffer.size();
fwrite(&buffer[0], 1, binary_size, file); fwrite(&buffer[0], 1, binary_size, file);
return binary_size; return binary_size;
......
...@@ -188,7 +188,7 @@ class BaseMapNode { ...@@ -188,7 +188,7 @@ class BaseMapNode {
bool SaveIntensityImage(const std::string& path) const; bool SaveIntensityImage(const std::string& path) const;
/**@brief The map settings. */ /**@brief The map settings. */
const BaseMapConfig* map_config_; const BaseMapConfig* map_config_ = nullptr;
/**@brief The index of this node. */ /**@brief The index of this node. */
MapNodeIndex index_; MapNodeIndex index_;
/**@brief The left top corner of the map node in the global coordinate system. /**@brief The left top corner of the map node in the global coordinate system.
...@@ -205,7 +205,7 @@ class BaseMapNode { ...@@ -205,7 +205,7 @@ class BaseMapNode {
bool data_is_ready_; bool data_is_ready_;
/**@brief The body binary size in file. It's useful when reading and writing /**@brief The body binary size in file. It's useful when reading and writing
* files. */ * files. */
mutable unsigned int file_body_binary_size_; mutable unsigned int file_body_binary_size_ = 0;
/**@bried The compression strategy. */ /**@bried The compression strategy. */
CompressionStrategy* compression_strategy_; CompressionStrategy* compression_strategy_;
/**@brief The min altitude of point cloud in the node. */ /**@brief The min altitude of point cloud in the node. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册