flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
162.18k stars 26.64k forks source link

Catch exceptions when trying to decode state restoration saved datas #147458

Open seelrd opened 2 weeks ago

seelrd commented 2 weeks ago

In packages/flutter/lib/src/services/restoration.dart's _decodeRestorationData function, this function adds a try-catch block to catch any errors happening when calling StandardMessageCodec().decodeMessage(). A FormatException can occur in StandardMessageCodec().decodeMessage() if the data saved for state restoration is corrupted.

This fixes #147456.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

flutter-dashboard[bot] commented 2 weeks ago

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

goderbauer commented 1 week ago

Thanks for the contribution. Can you please add a test for this so we don't regress this in the future? Thank you!