changeset 864:6eaeec6806f2

Fix the issue of potential to free a wild pointer
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 22 Sep 2010 21:14:06 +0800
parents e6c107b2e271
children 48df0f97f09e
files src/redraw_man.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/redraw_man.c	Wed Sep 22 20:47:41 2010 +0800
+++ b/src/redraw_man.c	Wed Sep 22 21:14:06 2010 +0800
@@ -1362,7 +1362,7 @@
  */
 static int
 compute_area(coord_t *coord) {
-    static co_aix (*poses)[2];
+    static co_aix (*poses)[2] = NULL;
     static int max_poses = 0;
     geo_t *geo;
     int cnt, pos_cnt;
@@ -1373,7 +1373,8 @@
     }
 
     if(max_poses < (cnt * 2)) {
-	free(poses);
+	if(poses)
+	    free(poses);
 	max_poses = cnt * 2;
 	poses = (co_aix (*)[2])malloc(sizeof(co_aix [2]) * max_poses);
 	if(poses == NULL)