[Freeciv-Dev] Unsafe assertions. (PR#864)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
The recent discussion about normalize_map_pos() has brought to my
attention a potential problem with the way we use it:
donald:~/freeciv$ grep --binary-files without-match -r assert.*norm *
client/goto.c: assert(normalize_map_pos(&x, &y));
client/goto.c: assert(normalize_map_pos(&x1, &y1));
client/goto.c: assert(normalize_map_pos(&new_x, &new_y));
client/goto.c: assert(normalize_map_pos(&dest_x, &dest_y));
client/gui-gtk/mapview.c: assert(normalize_map_pos(&dest_x, &dest_y));
client/gui-gtk/mapview.c: assert(normalize_map_pos(&dest_x, &dest_y));
client/gui-gtk/mapview.c: assert(normalize_map_pos(&dest_x, &dest_y));
client/gui-gtk/mapview.c: assert(normalize_map_pos(&dest_x, &dest_y));
client/gui-gtk/mapview.c: assert(normalize_map_pos(&dest_x, &dest_y));
client/gui-gtk/mapview.c: assert(normalize_map_pos(&dest_x, &dest_y));
client/gui-gtk/mapview.c: assert(normalize_map_pos(&x, &y));
client/gui-mui/graphics.c: assert(normalize_map_pos(&dest_x, &dest_y));
client/gui-mui/graphics.c: assert(normalize_map_pos(&x, &y));
client/gui-mui/mapclass.c: assert(normalize_map_pos(&dest_x, &dest_y));
client/gui-mui/mapclass.c: assert(normalize_map_pos(&dest_x, &dest_y));
client/gui-mui/mapclass.c: assert(normalize_map_pos(&dest_x, &dest_y));
client/gui-mui/mapclass.c: assert(normalize_map_pos(&dest_x,
&dest_y));
client/gui-mui/mapclass.c: assert(normalize_map_pos(&dest_x,
&dest_y));
client/gui-xaw/mapview.c: assert(normalize_map_pos(&dest_x, &dest_y));
client/gui-xaw/mapview.c: assert(normalize_map_pos(&dest_x, &dest_y));
client/gui-xaw/mapview.c: assert(normalize_map_pos(&dest_x, &dest_y));
client/gui-xaw/mapview.c: assert(normalize_map_pos(&dest_x, &dest_y));
common/map.c: assert(normalize_map_pos(&x, &y));
common/map.c: assert(normalize_map_pos(x, y));
server/citytools.c: assert(normalize_map_pos(&map_x, &map_y));
server/mapgen.c: assert(normalize_map_pos(&map_x, &map_y));
The reason this is dangerous is that normaliz_map_pos() will sometimes
change the value of x. If we compile with NDEBUG, this does not
happen, and a crash may occur.
I think we should changes these uses to is_real_tile() instead, and
use normalize_map_pos() explicitly if we rely on the value of x being
normalised afterwards.
--
Big Gaute http://www.srcf.ucam.org/~gs234/
I appoint you ambassador to Fantasy Island!!!
- [Freeciv-Dev] Unsafe assertions. (PR#864),
Gaute B Strokkenes <=
|
|