mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 13:50:13 +00:00
BACKENDS: Fix undefined parsing of timestamps file
DefaultSaveFileManager::loadTimestamps() was parsing strings from the
timestamps file by checking for end-of-stream after using the byte it
attempted to read. This worked because ReadStream::readByte() returns 0
on error, but that's undefined behavior with a FIXME to remove.
This bug was exposed by the recently added warning when 0 is appended
to a String: ab06f27d43
This commit is contained in:
parent
8f60095c89
commit
9987cc4c5b
@ -309,8 +309,9 @@ Common::HashMap<Common::String, uint32> DefaultSaveFileManager::loadTimestamps()
|
||||
while (!file->eos()) {
|
||||
//read filename into buffer (reading until the first ' ')
|
||||
Common::String buffer;
|
||||
while (!file->eos()) {
|
||||
while (true) {
|
||||
byte b = file->readByte();
|
||||
if (file->eos()) break;
|
||||
if (b == ' ') break;
|
||||
buffer += (char)b;
|
||||
}
|
||||
@ -320,8 +321,9 @@ Common::HashMap<Common::String, uint32> DefaultSaveFileManager::loadTimestamps()
|
||||
while (true) {
|
||||
bool lineEnded = false;
|
||||
buffer = "";
|
||||
while (!file->eos()) {
|
||||
while (true) {
|
||||
byte b = file->readByte();
|
||||
if (file->eos()) break;
|
||||
if (b == ' ' || b == '\n' || b == '\r') {
|
||||
lineEnded = (b == '\n');
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user