Skip to content

Commit 088330c

Browse files
committed
clip out of range values when we go to labs
1 parent 75174cd commit 088330c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

libvips/colour/Lab2LabS.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* - cleanups
88
* 20/9/12
99
* - redo as a class
10+
* 13/7/24
11+
* - clip out of range values
1012
*/
1113

1214
/*
@@ -61,9 +63,9 @@ vips_Lab2LabS_line(VipsColour *colour, VipsPel *out, VipsPel **in, int width)
6163
int i;
6264

6365
for (i = 0; i < width; i++) {
64-
q[0] = p[0] * (32767.0 / 100.0);
65-
q[1] = p[1] * (32768.0 / 128.0);
66-
q[2] = p[2] * (32768.0 / 128.0);
66+
q[0] = VIPS_CLIP(0, p[0] * (32767.0 / 100.0), SHRT_MAX);
67+
q[1] = VIPS_CLIP(SHRT_MIN, p[1] * (32768.0 / 128.0), SHRT_MAX);
68+
q[2] = VIPS_CLIP(SHRT_MIN, p[2] * (32768.0 / 128.0), SHRT_MAX);
6769

6870
q += 3;
6971
p += 3;

0 commit comments

Comments
 (0)