Skip to content

Commit 8dbacaf

Browse files
committed
fix overflow in cast for ImageBlurGaussian
1 parent 55a5674 commit 8dbacaf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/rtextures.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,9 +2217,9 @@ void ImageBlurGaussian(Image *image, int blurSize)
22172217
else if (pixelsCopy1[i].w <= 255.0f)
22182218
{
22192219
float alpha = (float)pixelsCopy1[i].w/255.0f;
2220-
pixels[i].r = (unsigned char)((float)pixelsCopy1[i].x/alpha);
2221-
pixels[i].g = (unsigned char)((float)pixelsCopy1[i].y/alpha);
2222-
pixels[i].b = (unsigned char)((float)pixelsCopy1[i].z/alpha);
2220+
pixels[i].r = (unsigned char)fminf((float)pixelsCopy1[i].x/alpha, 255.0);
2221+
pixels[i].g = (unsigned char)fminf((float)pixelsCopy1[i].y/alpha, 255.0);
2222+
pixels[i].b = (unsigned char)fminf((float)pixelsCopy1[i].z/alpha, 255.0);
22232223
pixels[i].a = (unsigned char) pixelsCopy1[i].w;
22242224
}
22252225
}

0 commit comments

Comments
 (0)