Skip to content

Commit

Permalink
tokenreader: negative file sizes are illegal
Browse files Browse the repository at this point in the history
  • Loading branch information
kazzmir committed Feb 8, 2024
1 parent 2fc2325 commit e5754c7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/r-tech1/tokenreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ class BufferedStream{
data(NULL),
position(0),
size(input.getSize()){
if (input.getSize() == 0){
throw TokenException(__FILE__, __LINE__, "File has size 0");
if (input.getSize() <= 0){
ostringstream error;
error << "File had invalid size " << input.getSize();
throw TokenException(__FILE__, __LINE__, error.str());
}
data = new unsigned char[size];
input.readLine((char*) data, size);
Expand Down

0 comments on commit e5754c7

Please sign in to comment.