Skip to content

Commit

Permalink
TESTS: Assert if size < 0 in gtest's GetFileSize()
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed May 23, 2018
1 parent ca0dbf4 commit f58031e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/googletest/src/gtest-port.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,11 @@ std::string TempDir() {

size_t GetFileSize(FILE* file) {
fseek(file, 0, SEEK_END);
return static_cast<size_t>(ftell(file));

const long file_size = ftell(file);
GTEST_CHECK_(file_size >= 0);

return static_cast<size_t>(file_size);
}

std::string ReadEntireFile(FILE* file) {
Expand Down

0 comments on commit f58031e

Please sign in to comment.