some light work today
corrected invalid read in update_weights() when tab[i].parent was equal to -1
This commit is contained in:
parent
ae93873452
commit
a2fd180398
@ -6,7 +6,7 @@
|
|||||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/03/28 16:21:19 by tmaze #+# #+# */
|
/* Created: 2019/03/28 16:21:19 by tmaze #+# #+# */
|
||||||
/* Updated: 2019/04/05 15:13:53 by tmaze ### ########.fr */
|
/* Updated: 2019/04/07 12:50:24 by tmaze ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -19,6 +19,8 @@ static void update_weights(t_lmdata *data, t_bfs *tab, int end_ind)
|
|||||||
|
|
||||||
i = end_ind;
|
i = end_ind;
|
||||||
while (i != -1)
|
while (i != -1)
|
||||||
|
{
|
||||||
|
if (tab[i].parent != -1)
|
||||||
{
|
{
|
||||||
it = data->adj[tab[i].parent];
|
it = data->adj[tab[i].parent];
|
||||||
while (it && it->index != i)
|
while (it && it->index != i)
|
||||||
@ -30,6 +32,7 @@ static void update_weights(t_lmdata *data, t_bfs *tab, int end_ind)
|
|||||||
it = it->next;
|
it = it->next;
|
||||||
if (it && it->index == tab[i].parent)
|
if (it && it->index == tab[i].parent)
|
||||||
it->weight++;
|
it->weight++;
|
||||||
|
}
|
||||||
i = tab[i].parent;
|
i = tab[i].parent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user