Check ef_type before dereferencing struct empobj
Such manual checking is error prone, but the best we can do right now.
This commit is contained in:
parent
990b39edec
commit
5490782db3
7 changed files with 52 additions and 9 deletions
|
@ -67,26 +67,33 @@ nxtitemp(struct nstr_item *np)
|
|||
case NS_ALL:
|
||||
break;
|
||||
case NS_DIST:
|
||||
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
|
||||
return 0;
|
||||
if (!xyinrange(gp->x, gp->y, &np->range)) {
|
||||
selected = 0;
|
||||
break;
|
||||
}
|
||||
np->curdist = mapdist((int)gp->x, (int)gp->y,
|
||||
(int)np->cx, (int)np->cy);
|
||||
np->curdist = mapdist(gp->x, gp->y, np->cx, np->cy);
|
||||
if (np->curdist > np->dist)
|
||||
selected = 0;
|
||||
break;
|
||||
case NS_AREA:
|
||||
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
|
||||
return 0;
|
||||
if (!xyinrange(gp->x, gp->y, &np->range))
|
||||
selected = 0;
|
||||
if (gp->x == np->range.hx || gp->y == np->range.hy)
|
||||
selected = 0;
|
||||
break;
|
||||
case NS_XY:
|
||||
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
|
||||
return 0;
|
||||
if (xnorm(gp->x) != np->cx || ynorm(gp->y) != np->cy)
|
||||
selected = 0;
|
||||
break;
|
||||
case NS_GROUP:
|
||||
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_GROUP)))
|
||||
return 0;
|
||||
if (np->group != gp->group)
|
||||
selected = 0;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue