[gnome-games] retro: Don't try to load the state if its size is wrong



commit d27b38258255ea4324b75cf319ff257f00cc1038
Author: Mathieu Bridon <bochecha daitauha fr>
Date:   Sun Aug 14 17:04:32 2016 +0200

    retro: Don't try to load the state if its size is wrong
    
    The core is supposed to return serialized data of a certain, expected
    size.
    
    Unfortunately, they often don't.
    
    When that happens, we probably shouldn't try to load the serialized
    state, as it is potentially bad.
    
    Unfortunately, it might also be correct.
    
    If we don't load such serialized data and it was correct, the player
    will lose the state of their game, which is pretty bad.
    
    However if we try loading such serialized data and it was bad, then the
    core will just completely freeze the whole application, with no way for
    the user to even close it.
    
    The second option seems even worse, so with this commit we throw an
    error when the size wasn't the expected one.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769938

 src/retro/retro-runner.vala |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 2160619..ffdd7e2 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -384,7 +384,8 @@ public class Games.RetroRunner : Object, Runner {
 
                var expected_size = core.serialize_size ();
                if (data.length != expected_size)
-                       warning ("Unexpected serialization data size: got %lu, expected %lu\n", data.length, 
expected_size);
+                       /* Not translated as this is not presented to the user */
+                       throw new RetroError.COULDNT_LOAD_SNAPSHOT ("[%s] Unexpected serialization data size: 
got %lu, expected %lu\n", core.file_name, data.length, expected_size);
 
                if (!core.unserialize (data))
                        /* Not translated as this is not presented to the user */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]