Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aeef93a

Browse files
committed
Fix matplotlib#2418: Crash in PDF backend due to complicated clipping pattern.
1 parent e4ec9d5 commit aeef93a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,11 +2139,12 @@ def clip_cmd(self, cliprect, clippath):
21392139
"""Set clip rectangle. Calls self.pop() and self.push()."""
21402140
cmds = []
21412141
# Pop graphics state until we hit the right one or the stack is empty
2142-
while (self._cliprect, self._clippath) != (cliprect, clippath) \
2143-
and self.parent is not None:
2142+
while ((self._cliprect, self._clippath) != (cliprect, clippath)
2143+
and self.parent is not None):
21442144
cmds.extend(self.pop())
21452145
# Unless we hit the right one, set the clip polygon
2146-
if (self._cliprect, self._clippath) != (cliprect, clippath):
2146+
if ((self._cliprect, self._clippath) != (cliprect, clippath) or
2147+
self.parent is None):
21472148
cmds.extend(self.push())
21482149
if self._cliprect != cliprect:
21492150
cmds.extend([cliprect, Op.rectangle, Op.clip, Op.endpath])

0 commit comments

Comments
 (0)