Oops when unit_carrier_change() arguments OLD or NEW are invalid

This commit is contained in:
Markus Armbruster 2008-10-18 14:21:45 -04:00
parent 488b80841b
commit c0c416b011

View file

@ -186,9 +186,9 @@ unit_carrier_change(struct empobj *cargo, int type, int old, int new)
{ {
if (CANT_HAPPEN(type < 0 || type > EF_NUKE)) if (CANT_HAPPEN(type < 0 || type > EF_NUKE))
return; return;
if (old >= 0) if (old >= 0 && !CANT_HAPPEN(old >= nclink[type]))
clink_rem(&clink[type][old], cargo->ef_type, cargo->uid); clink_rem(&clink[type][old], cargo->ef_type, cargo->uid);
if (new >= 0) if (new >= 0 && !CANT_HAPPEN(new >= nclink[type]))
clink_add(&clink[type][new], cargo->ef_type, cargo->uid); clink_add(&clink[type][new], cargo->ef_type, cargo->uid);
} }