summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-03-02 22:33:38 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-03-02 22:33:38 +0100
commitb948ba030ca3b49a79b1e77a87229438209e422c (patch)
treefd0998dad73a82a3e4f1eef2726773a89f754126
parent17710741242f40c91edb28f29d6e5ef943a4c41b (diff)
Reserve new space to data_ can_message_t member only if the
new incoming can frame if bigger than the old one. Change-Id: I39634cc0d01b300ea471b358e13d704b8eff351c Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--src/can-message.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/can-message.cpp b/src/can-message.cpp
index 5a3e2c27..63f8a909 100644
--- a/src/can-message.cpp
+++ b/src/can-message.cpp
@@ -182,7 +182,8 @@ void can_message_t::convert_from_canfd_frame(const std::pair<struct canfd_frame&
if(maxdlen_ == CANFD_MAX_DLEN)
set_flags(frame.flags);
- data_.reserve(maxdlen_);
+ if ( data_.capacity() < maxdlen_)
+ data_.reserve(maxdlen_);
set_data(frame.data);
DEBUG(binder_interface, "convert_from_canfd_frame: Found id: %X, format: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X", id_, format_, length_,