Mercurial > MadButterfly
comparison src/redraw_man.c @ 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 | ce6cd06adccf |
children | 48df0f97f09e |
comparison
equal
deleted
inserted
replaced
863:e6c107b2e271 | 864:6eaeec6806f2 |
---|---|
1360 | 1360 |
1361 /*! \brief Compute area of a coord. | 1361 /*! \brief Compute area of a coord. |
1362 */ | 1362 */ |
1363 static int | 1363 static int |
1364 compute_area(coord_t *coord) { | 1364 compute_area(coord_t *coord) { |
1365 static co_aix (*poses)[2]; | 1365 static co_aix (*poses)[2] = NULL; |
1366 static int max_poses = 0; | 1366 static int max_poses = 0; |
1367 geo_t *geo; | 1367 geo_t *geo; |
1368 int cnt, pos_cnt; | 1368 int cnt, pos_cnt; |
1369 | 1369 |
1370 cnt = 0; | 1370 cnt = 0; |
1371 FORMEMBERS(coord, geo) { | 1371 FORMEMBERS(coord, geo) { |
1372 cnt++; | 1372 cnt++; |
1373 } | 1373 } |
1374 | 1374 |
1375 if(max_poses < (cnt * 2)) { | 1375 if(max_poses < (cnt * 2)) { |
1376 free(poses); | 1376 if(poses) |
1377 free(poses); | |
1377 max_poses = cnt * 2; | 1378 max_poses = cnt * 2; |
1378 poses = (co_aix (*)[2])malloc(sizeof(co_aix [2]) * max_poses); | 1379 poses = (co_aix (*)[2])malloc(sizeof(co_aix [2]) * max_poses); |
1379 if(poses == NULL) | 1380 if(poses == NULL) |
1380 return ERR; | 1381 return ERR; |
1381 } | 1382 } |