Commit 78b3098b authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Avoid overflow in neighbour_cost.

Thanks to Yoann Canal.
parent 449c8d59
......@@ -364,7 +364,7 @@ neighbour_cost(struct neighbour *neigh)
directions. */
a = MAX(a, 256);
b = MAX(b, 256);
/* 1/(alpha * beta), which is just plain ETX. */
return ((a * b + 128) >> 8);
/* 1/(alpha * beta), which is just plain ETX. Avoid overflow. */
return ((a + 8) >> 4) * ((b + 8) >> 4);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment