]> git.tuebingen.mpg.de Git - paraslash.git/commit
mood.c: Avoid integer underflow.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 15 Mar 2016 19:48:12 +0000 (20:48 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 15 Mar 2016 21:03:11 +0000 (22:03 +0100)
commita37f31bbe4f1b2745ef0f617cff122a2c5f95078
tree011f9f4a5ae5d52b2b763d0389842ccdac6a4f4b
parent58566e1535a0c47ce59570598885ccabc75891bf
mood.c: Avoid integer underflow.

The three variables x, s, n are all of unsigned type, and the
subtraction x - s / n may underflow, resulting in a very large positive
value. This should not matter since we square the difference, but on
the other hand, the underflow can easily be avoided. This patch uses
a temporary variable to do so.
mood.c