Fix crash bug in satellite maps
The value of diffx() had the wrong sign when the arguments differed by WORLD_X / 2. Same for diffy() and WORLD_Y / 2. satmap() used them to find the vector from map center to ship or land unit to put on the map, and got incorrect values for ships and land units directly opposite to the center in x or y. The bug made satmap() read a pointer out bounds of its malloced radbuf[], and then write through that with unpredictable consequences. Broken in 4.2.12. The original bug was in Empire 1.1: it miscalculated where to put ships on the map (no crash). An incomplete fix for radmap() and satmap() appeared in Chainsaw 2 (still no crash). radmap() got fixed correctly in Chainsaw 3, but satmap() was forgotten. That one got "fixed" in 4.2.7, and again in 4.2.12, but both "fixes" were flawed and could crash. Fix by backing out the flawed fixes and adopting the fix from radmap() instead.
This commit is contained in:
parent
7680acc39f
commit
0cc474bd6d
3 changed files with 4 additions and 48 deletions
|
@ -281,8 +281,6 @@ extern int logreopen(void);
|
|||
extern void logerror(char *, ...) ATTRIBUTE((format (printf, 1, 2)));
|
||||
/* more in misc.h */
|
||||
/* mapdist.c */
|
||||
extern int diffx(int, int);
|
||||
extern int diffy(int, int);
|
||||
extern int deltax(int, int);
|
||||
extern int deltay(int, int);
|
||||
extern int mapdist(int, int, int, int);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue