Package: xonix / 1.4-31

50-x11.c-free.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From: Jari Aalto <jari.aalto@cante.net>
Subject: Check pointer before calling free()

---
 x11.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

--- a/x11.c
+++ b/x11.c
@@ -963,7 +963,8 @@
     }
     else
 	fprintf(stderr, "xonix: cannot open high score file\n");
-    free(fullname);
+    if (fullname)
+	free(fullname);
     gameover_pending = 0;
     return;
   }
@@ -973,7 +974,8 @@
   
   if(numentries >= MAXSCORES && gHighScore <= score_rec[0].score) {
     /* sorry, not among top ten */
-    free(fullname);
+    if (fullname)
+	free(fullname);
     if(flock(fileno(high),LOCK_UN) != 0)
       fprintf(stderr, "xonix: cannot unlock high score file\n");
     fclose(high);
@@ -1058,7 +1060,8 @@
   memset(score_rec[i].full, 0, 65);
   strncpy(score_rec[i].full, fullname, 64);
   score_rec[i].tstamp = time(NULL);
-  free(fullname);
+  if (fullname)
+      free(fullname);
 
   if((high = freopen(PATH_HIGHSCORE, "w",high)) == NULL) {
     fprintf(stderr, "xonix: cannot reopen high score file\n");