mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Replace harcoded assumption of RAND_MAX with constant. It caused an infinite loop if RAND_MAX > 32767
This commit is contained in:
parent
2c70c9e5e9
commit
f1333617d5
|
@ -98,8 +98,8 @@ ImagingEffectNoise(int xsize, int ysize, float sigma)
|
|||
/* after numerical recipes */
|
||||
double v1, v2, radius, factor;
|
||||
do {
|
||||
v1 = rand()*(2.0/32767.0) - 1.0;
|
||||
v2 = rand()*(2.0/32767.0) - 1.0;
|
||||
v1 = rand()*(2.0/RAND_MAX) - 1.0;
|
||||
v2 = rand()*(2.0/RAND_MAX) - 1.0;
|
||||
radius= v1*v1 + v2*v2;
|
||||
} while (radius >= 1.0);
|
||||
factor = sqrt(-2.0*log(radius)/radius);
|
||||
|
|
Loading…
Reference in New Issue
Block a user