On Thursday 31 October 2002 6:02 am, Rob Lahaye wrote:
> Hi,
>
> The attached patch fixes an image clipping bug in
> xformsImage.C. The patch fixes the following type of error:
>
>     int i = 5;
>     unsigned int ui = 20;
>     int offset = std::max(0U, i - ui);
>
> Here, (i - ui) is converted to unsigned int.
> If (i - ui) is negative, then this is converted to a very
> large unsigned number and thus the std::max returns the
> unsigned int (i - ui). This is finally converted to a normal
> int, which becomes negative. In the above example, offset does
> not become zero, but -15 !!!!
>
> I discovered this error,when flimage_clip() crashed with
> negative offset values (although all offsets where calculated
> with std::max). After my patch, the crash disappeared.
>
>
> Please have a look at the attached patch and apply if OK.
>
> Regards,
> Rob.

Thanks, Rob. Applied.
Angus

Reply via email to