Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix heap overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
arcadiaphy committed Feb 22, 2019
1 parent d85ee88 commit 43fde1a
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ class BufferFile {
ifs.seekg(0, std::ios::beg);
std::cout << file_path.c_str() << " ... " << length_ << " bytes\n";

buffer_.reset(new char[length_]);
// Buffer as null terminated to be converted to string
buffer_.reset(new char[length_ + 1]);
buffer_[length_] = 0;
ifs.read(buffer_.get(), length_);
ifs.close();
}
Expand Down

0 comments on commit 43fde1a

Please sign in to comment.