-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading all saves at start and not checking each read for errors. #151
Comments
I'm verifing the length of the decompressed buffer. And I am checking filename to make sure it's slot is < 2 and the game number is < 30. And total file size compressed must be atleast 5 bytes so I can read the filesize and have something to decompress. #151
…one. you can pass size 0 to skip size check. but if we know what the size should be we can confirm it is right. #151
I think loading of saves on demand will be useful as we won't need to clone the save into memory if we are reading from the drive Everytime we goto load. We can just assign the loaded save into memory and let the garage collector eat the rest. Probably will need to read only enough data to display what is on the save Lord screen. Though we still need to read the entire file because it is compressed. Maybe we can add a cutoff value to lzs. Saying we only need X bytes stop decompressing if past that point. Maybe I'll do this next week. |
It was pointed out that a save could be corrupt. Causing crashes.
Two ways to avoid is to verify the reads for each variable. Or put the whole thing in try catch block.
Though might be good to use a try catch block. I worry about it masking problems that exist in the code.
We could also check each read making sure we aren't past the max length and that the value read is valid for each one. Max length could be checked up front. calculating the total bytes it should be and making sure at first the file is the right length. Though everything is lzss compressed which gives us the length the file should be after decompressing.
Loading all saves isn't required. We can move it to the load menu. Could just read the part we need for the menu, like the real game does even.
maybe related: #61
The text was updated successfully, but these errors were encountered: