Fix accessing of first character of an empty string.
GitOrigin-RevId: 9a4f25e6f46bacb397b43c88665a71da929a5531
This commit is contained in:
parent
4fb3506792
commit
d30d227289
@ -31,12 +31,14 @@ std::string get_file_contents(const std::string &file_name, const std::string &m
|
||||
std::size_t size = static_cast<std::size_t>(size_long);
|
||||
|
||||
std::string result(size, ' ');
|
||||
if (size != 0) {
|
||||
std::rewind(f);
|
||||
std::size_t fread_res = std::fread(&result[0], size, 1, f);
|
||||
if (size != 0 && fread_res != 1) {
|
||||
if (fread_res != 1) {
|
||||
std::fprintf(stderr, "Can't read file \"%s\"", file_name.c_str());
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
std::fclose(f);
|
||||
|
||||
return result;
|
||||
|
Reference in New Issue
Block a user