mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Bridges: fix an out-of-bounds read.
Occurs when dragging from an island next to an edge in the direction of that edge. This bug was discovered using ASan.
This commit is contained in:

committed by
Simon Tatham

parent
05f4f6349f
commit
ebb50f0af2
@ -2306,11 +2306,15 @@ static char *update_drag_dst(const game_state *state, game_ui *ui,
|
||||
if (abs(nx-ox) < abs(ny-oy)) {
|
||||
dx = 0;
|
||||
dy = (ny-oy) < 0 ? -1 : 1;
|
||||
if (!INGRID(state, ui->dragx_src+dx, ui->dragy_src+dy))
|
||||
return MOVE_UI_UPDATE;
|
||||
gtype = G_LINEV; ntype = G_NOLINEV; mtype = G_MARKV;
|
||||
maxb = INDEX(state, maxv, ui->dragx_src+dx, ui->dragy_src+dy);
|
||||
} else {
|
||||
dy = 0;
|
||||
dx = (nx-ox) < 0 ? -1 : 1;
|
||||
if (!INGRID(state, ui->dragx_src+dx, ui->dragy_src+dy))
|
||||
return MOVE_UI_UPDATE;
|
||||
gtype = G_LINEH; ntype = G_NOLINEH; mtype = G_MARKH;
|
||||
maxb = INDEX(state, maxh, ui->dragx_src+dx, ui->dragy_src+dy);
|
||||
}
|
||||
|
Reference in New Issue
Block a user