Skip to content
Prev 6465 / 63424 Next

pdf() behavior (PR#1174)

Once again, this has nothing to do with pdf()!

The bug is in the internal clipping code in graphics.c, which read

    default: /* Partial clipping; draw poly[line|gon] */
        dd->gp.xpd = 2;
        result2 = clipCircleCode(x, y, coords, ir, dd);
        dd->gp.xpd = xpdsaved;
        if (dd->dp.canClip && result2 == -2) {
            GClip(dd);
            dd->dp.circle(x, y, coords, ir, bg, fg, dd);
        }
        else {
            vmax = vmaxget();
            xc = (double*)R_alloc(result+1, sizeof(double));
            yc = (double*)R_alloc(result+1, sizeof(double));

with result, not result2.  This meant that if a circle was clipped by the
plot region but not by the device region, result got set to -2, and the
final lines tried to allocate a vector of size -1.  As the postscript
device has dd->dp.canClip true, the bug was avoided on that device.

I don't fully understand the intended logic: is this fix the correct one,
Paul or Ross?  And can we have some comments in the code, please?
On Thu, 15 Nov 2001 White.Denis@epamail.epa.gov wrote: