Skip to content
Open
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: 2 additions & 2 deletions src/common/util/src/file_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ std::filesystem::path ov::util::get_plugin_path(const std::filesystem::path& plu
std::vector<uint8_t> ov::util::load_binary(const std::filesystem::path& path) {
std::vector<uint8_t> buffer;
if (auto input = std::ifstream(path, std::ios::binary); input.is_open()) {
buffer.reserve(std::filesystem::file_size(path));
input.read(reinterpret_cast<char*>(buffer.data()), buffer.capacity());
buffer.resize(std::filesystem::file_size(path));
input.read(reinterpret_cast<char*>(buffer.data()), buffer.size());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be test be added to reproduce the issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@praasz As you know, 'reserve() does not change the size of the vector.'
Refer link: https://en.cppreference.com/w/cpp/container/vector/reserve

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it could be fix using back inserter and still use reserve
But test could be added to catch the issue

}
return buffer;
}
Expand Down
Loading