[comp.windows.x] Clip problem in sample server

rlkd@opusys.UUCP (R.L.K.Dattatri) (05/10/89)

This is a problem found in the 'mfb' code.

In the file 'mfbline.c', the routine 'mfbDashLine()' uses the macros
ceiling and round. The comments state that they are valid for denominators
of positive values. But the code does not take care of it!!

Here is what happened.

While using the bitmap editor (bitmap) to edit the 'woman' bitmap, I bumped
into EFPE (floating point exception, divide by zero). This was traced down to
the code in 'mfbClipLine'. When the line is horizontal/vertical the values
of 'adx' or 'ady' is zero. Thus a call to round or ceiling causes EFPE.

This happens when you select the default size window put up by 'uwm'.
I was running on a hercules monitor (720x348 resolution). If the window is
fixed to a particular size (using uwm) the problem will not arise.

I found a temporary solution to this:

The mfbClipLine code checks the points to be clipped against the box boundaries.
If the line is horizontal/vertical we need to set the point to the window
boundary (box) itself. However this may lead to an infinite loop if the
flag 'clipDone' is not set. Thus whenever there is a call to ceiling or
round (where necessary) add an 'if' to check for 'adx (ady)' being not NULL.
If it is NULL set the corresponding coordinate (x or y) to the corresponding
box boundary.

Has anyone encountered this problem??

R.L.K. Dattatri
Opus Systems
uunet!opusys!rlkd