~ubuntu-branches/ubuntu/karmic/gnome-games/karmic-proposed

« back to all changes in this revision

Viewing changes to debian/patches/03_sudoku_crash_saved_files.patch

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2009-04-14 12:31:51 UTC
  • mfrom: (1.1.65)
  • Revision ID: package-import@ubuntu.com-20090414123151-v18w2slnw6nx1f4d
Tags: 1:2.26.1-0ubuntu1
New upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Index: gnome-games-2.26.0/gnome-sudoku/src/lib/saver.py
2
 
===================================================================
3
 
--- gnome-games-2.26.0/gnome-sudoku/src/lib/saver.py    2009/03/28 00:47:14     8910
4
 
+++ gnome-games-2.26.0/gnome-sudoku/src/lib/saver.py    2009/03/28 02:05:39     8911
5
 
@@ -211,8 +211,22 @@
6
 
             except:
7
 
                 print 'Warning: could not read file',f
8
 
             else:
9
 
-                jar['saved_at']=os.stat(f)[8]
10
 
-                games.append(jar)
11
 
+                if self.is_valid(jar):
12
 
+                    jar['saved_at']=os.stat(f)[8]
13
 
+                    games.append(jar)
14
 
+                else:
15
 
+                    print 'Warning: malformed save game',f
16
 
         return games
17
 
-        
18
 
+
19
 
+    def is_valid (self, jar):
20
 
+        virgin = jar['game'].split('\n')[0].replace(' ','')
21
 
+        played = jar['game'].split('\n')[1].replace(' ','')
22
 
+
23
 
+        if len(virgin) != 81 or len(played) != 81:
24
 
+            return False
25
 
+
26
 
+        if not virgin.isdigit() or not played.isdigit():
27
 
+            return False
28
 
+
29
 
+        return True
30