Skip to content

Commit

Permalink
Fix unable to save/load issue (on Steam exe only)
Browse files Browse the repository at this point in the history
 - This issue was caused by the lack of a null terminator when reading the save location from the saveloc.txt file, resulting in the game attempting to read a path with some junk at the end
 - Previously, only the first element of the array was initialized. Any bytes not overwritten by fread(...) would remain uninitialized.
 - I also modified fread to read 511 instead of 512 bytes, so that there will always be a null terminator, even if fread reads the full 511 bytes.
  • Loading branch information
drojf authored and TellowKrinkle committed Oct 13, 2021
1 parent e9c7e03 commit ecc3c3a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/PonscripterLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,11 +883,10 @@ pstring Steam_GetSavePath(const pstring& local_savedir) {
pstring saveloc = savedirdir + "saveloc.txt";

FILE* savelocfile = fopen(saveloc, "r");
char path[512];
char path[512] = { 0 };
pstring savelocContent;
path[0] = 0;
if (savelocfile) {
while (fread(path, 1, sizeof(path), savelocfile)) {
while (fread(path, 1, sizeof(path)-1, savelocfile)) {
savelocContent += path;
}
fclose(savelocfile);
Expand Down

0 comments on commit ecc3c3a

Please sign in to comment.