Browse Source

String already adds a null terminator

master
Riyyi 4 years ago
parent
commit
bbd84df19c
  1. 4
      inferno/src/inferno/io/file.cpp

4
inferno/src/inferno/io/file.cpp

@ -29,14 +29,14 @@ namespace Inferno {
} }
// Allocate memory filled with zeros // Allocate memory filled with zeros
auto buffer = std::make_unique<char[]>(length + 1); auto buffer = std::make_unique<char[]>(length);
// Fill buffer with file contents // Fill buffer with file contents
file.read(buffer.get(), length); file.read(buffer.get(), length);
file.close(); file.close();
// Create string from the buffer and return // Create string from the buffer and return
return std::string(buffer.get(), length + 1); return std::string(buffer.get(), length);
} }
} }

Loading…
Cancel
Save