diff --git a/graf2d/gpad/src/TPad.cxx b/graf2d/gpad/src/TPad.cxx index 4566e37dacc36..098b65f5177b7 100644 --- a/graf2d/gpad/src/TPad.cxx +++ b/graf2d/gpad/src/TPad.cxx @@ -949,16 +949,20 @@ Int_t TPad::ClippingCode(Double_t x, Double_t y, Double_t xcl1, Double_t ycl1, D Int_t TPad::ClipPolygon(Int_t n, Double_t *x, Double_t *y, Int_t nn, Double_t *xc, Double_t *yc, Double_t xclipl, Double_t yclipb, Double_t xclipr, Double_t yclipt) { + if (n <= 0) + return 0; + Int_t nc, nc2; Double_t x1, y1, x2, y2, slope; // Segment to be clipped std::vector xc2(nn), yc2(nn); // Clip against the left boundary - x1 = x[n-1]; y1 = y[n-1]; + x1 = x[n - 1]; + y1 = y[n - 1]; nc2 = 0; Int_t i; - for (i=0; i 0) { + x1 = xc2[nc2 - 1]; + y1 = yc2[nc2 - 1]; + } nc = 0; - for (i=0; i0) { - - // Clip against the right boundary - x1 = xc[nc-1]; y1 = yc[nc-1]; + // Clip against the right boundary + if (nc > 0) { + x1 = xc[nc - 1]; + y1 = yc[nc - 1]; nc2 = 0; - for (i=0; i 0) { + x1 = xc2[nc2 - 1]; + y1 = yc2[nc2 - 1]; + } nc = 0; - for (i=0; i