Minimum working example
#include <boost/filesystem.hpp> #include <boost/scoped_array.hpp> #include <boost/foreach.hpp> #include <string> #include <iostream> void TEST(const std::string& file_name) { if (!file_name.empty()) { std::ifstream input(file_name.c_str(), std::ios::binary); if (!input) { return; } int file_size = boost::filesystem::file_size(file_name); if (file_size <= 0) { return; } boost::scoped_array<char> buffer; buffer.reset(new char[file_size]); buffer[0] = '\0'; std::cout << buffer; } }
Cppcheck: error/containerOutOfBounds: Out of bounds access in expression 'buffer[0]' because 'buffer' is empty
I hope this is fixed. I can reproduce with cppcheck-2.0 but I can't reproduce with cppcheck-HEAD.
Log in to post a comment.
Minimum working example
Cppcheck:
error/containerOutOfBounds: Out of bounds access in expression 'buffer[0]' because 'buffer' is empty
I hope this is fixed. I can reproduce with cppcheck-2.0 but I can't reproduce with cppcheck-HEAD.