Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Fixed
- Fixed CanFdMessage64

## [2.0.1] - 2018-08-23
### Fixed
- Fixed memory leak with introduction of std::shared_ptr
Expand Down
4 changes: 4 additions & 0 deletions src/Vector/BLF/CanFdMessage64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ void CanFdMessage64::read(AbstractFile & is)
is.read(reinterpret_cast<char *>(&dir), sizeof(dir));
is.read(reinterpret_cast<char *>(&extDataOffset), sizeof(extDataOffset));
is.read(reinterpret_cast<char *>(&crc), sizeof(crc));
data.resize(validDataBytes);
is.read(reinterpret_cast<char *>(data.data()), static_cast<std::streamsize>(data.size()));
if (extDataOffset != 0) {
CanFdExtFrameData::read(is);
Expand All @@ -73,6 +74,9 @@ void CanFdMessage64::read(AbstractFile & is)

void CanFdMessage64::write(AbstractFile & os)
{
/* pre processing */
validDataBytes = static_cast<WORD>(data.size());
Copy link

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Casting data.size() to WORD may lead to overflow if data.size() ever exceeds WORD's maximum value. Consider adding a check or enforcing an upper bound.

Copilot uses AI. Check for mistakes.

ObjectHeader::write(os);
os.write(reinterpret_cast<char *>(&channel), sizeof(channel));
os.write(reinterpret_cast<char *>(&dlc), sizeof(dlc));
Expand Down
4 changes: 2 additions & 2 deletions src/Vector/BLF/CanFdMessage64.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <Vector/BLF/platform.h>

#include <array>
#include <vector>

#include <Vector/BLF/AbstractFile.h>
#include <Vector/BLF/CanFdExtFrameData.h>
Expand Down Expand Up @@ -196,7 +196,7 @@ class VECTOR_BLF_EXPORT CanFdMessage64 final : public ObjectHeader, public CanFd
* than 64 bytes, according to the value of
* dlc).
*/
std::array<BYTE, 64> data;
std::vector<uint8_t> data;
Copy link

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching from a fixed-size std::array to a dynamic std::vector alters memory allocation. Consider documenting the rationale for this change and evaluating potential performance impacts if data is always 64 bytes.

Copilot uses AI. Check for mistakes.
};

}
Expand Down
5 changes: 4 additions & 1 deletion src/Vector/BLF/docs/examples/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,7 @@ void show(Vector::BLF::CanFdMessage * obj)
void show(Vector::BLF::CanFdMessage64 * obj)
{
std::cout << "CanFdMessage64:";
std::cout << " channel=" << std::dec << obj->channel;
std::cout << " channel=" << std::dec << static_cast<uint16_t>(obj->channel);
std::cout << " dlc=" << std::dec << static_cast<uint16_t>(obj->dlc);
std::cout << " validDataBytes=" << std::dec << static_cast<uint16_t>(obj->validDataBytes);
std::cout << " txCount=" << std::dec << static_cast<uint16_t>(obj->txCount);
Expand Down Expand Up @@ -2479,6 +2479,9 @@ int main(int argc, char * argv[])
case Vector::BLF::ObjectType::ETHERNET_ERROR_FORWARDED:
show(reinterpret_cast<Vector::BLF::EthernetErrorForwarded *>(ohb));
break;

default:
std::cout << "Unknown ObjectType" << std::endl;
}

/* check objectSize */
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Vector/BLF/tests/unittests/test_CanFdMessage64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ BOOST_AUTO_TEST_CASE(CanFdMessage64)
/* CanFdMessage64 */
BOOST_CHECK_EQUAL(obj->channel, 0x11);
BOOST_CHECK_EQUAL(obj->dlc, 0x22);
BOOST_CHECK_EQUAL(obj->validDataBytes, 0x33);
BOOST_CHECK_EQUAL(obj->validDataBytes, 0x40);
BOOST_CHECK_EQUAL(obj->txCount, 0x44);
BOOST_CHECK_EQUAL(obj->id, 0x55555555);
BOOST_CHECK_EQUAL(obj->frameLength, 0x66666666);
Expand Down