mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-04 01:07:22 +00:00
HOPKINS: Add null termination to byte buffer returned by loadFile().
This shouldn't be a problem, as current client code either must find a terminator when parsing the byte buffer or have preknowledge of the buffer size from a file size or fixed call, so the appended null termination will not cause issues. This change thus allows client code to add sanity checks to prevent reading off the end of the buffer.
This commit is contained in:
parent
3ceaafd1f9
commit
71aab5ab1d
@ -51,12 +51,13 @@ byte *FileManager::loadFile(const Common::String &file) {
|
||||
|
||||
// Allocate space for the file contents
|
||||
size_t filesize = f.size();
|
||||
byte *data = _vm->_globals->allocMemory(filesize);
|
||||
byte *data = _vm->_globals->allocMemory(filesize+1);
|
||||
if (!data)
|
||||
error("Error allocating space for file being loaded - %s", file.c_str());
|
||||
|
||||
readStream(f, data, filesize);
|
||||
f.close();
|
||||
data[filesize] = '\0';
|
||||
|
||||
return data;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user