Bug-fix: Clamp backward dist to 1.

Check for valid bounds on the 'dist' in backward reference case.
Clamp it to 1 in case of zero and negative values.

Change-Id: I78e956d4595955efa02b1f9628b475093f6ee001
This commit is contained in:
Vikas Arora 2012-06-19 16:42:07 +05:30
parent b5b6ac979f
commit 8a69c7d8af

View File

@ -139,7 +139,8 @@ static WEBP_INLINE int PlaneCodeToDistance(int xsize, int plane_code) {
const int dist_code = code_to_plane_lut[plane_code - 1];
const int yoffset = dist_code >> 4;
const int xoffset = 8 - (dist_code & 0xf);
return yoffset * xsize + xoffset;
int dist = yoffset * xsize + xoffset;
return (dist >= 1) ? dist : 1;
}
}