mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 18:56:17 +03:00
Corrected undefined behaviour
This commit is contained in:
parent
1b9a41f2de
commit
eebe3ea923
|
@ -79,6 +79,7 @@ ImagingEffectNoise(int xsize, int ysize, float sigma)
|
|||
Imaging imOut;
|
||||
int x, y;
|
||||
int nextok;
|
||||
int d;
|
||||
double this, next;
|
||||
|
||||
imOut = ImagingNewDirty("L", xsize, ysize);
|
||||
|
@ -106,7 +107,8 @@ ImagingEffectNoise(int xsize, int ysize, float sigma)
|
|||
this = factor * v1;
|
||||
next = factor * v2;
|
||||
}
|
||||
out[x] = (unsigned char) (128 + sigma * this);
|
||||
d = 128 + sigma * this;
|
||||
out[x] = d<0 ? 0 : (d>UCHAR_MAX ? UCHAR_MAX : d);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user