Be aware of subtle overflow

Tags:

http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html

We see the following form of code very often.

int low = ...;
int high = ...;
int mid =(low + high) / 2;

But be aware of subtle overflow here. low + high can be larger than the maximum value of int range. Open ssh vunlerability was also due to subtle overflow.