FileUtil: check for errors after a fread() in ReadFileToString()

This commit is contained in:
Sean McGovern 2021-05-11 23:40:49 -04:00
parent 4cc34e384c
commit 9e106e1d3d

View File

@ -896,7 +896,8 @@ bool ReadFileToString(bool text_file, const char *filename, std::string &str) {
success = true;
} else {
str.resize(len);
success = fread(&str[0], 1, len, f) == len;
int read = fread(&str[0], 1, len, f);
success = read <= len && !ferror(f);
}
fclose(f);
return success;