Bug#894206: dxf2gcode: Traceback related to empty self.geo in polyline and lwpolyline

Sebastian Reichel sre at debian.org
Tue Mar 27 10:46:18 UTC 2018


Package: dxf2gcode
Version: 20170925-2
Severity: normal
Tags: upstream

Hi,

I managed to crash dxf2gcode in two different, but similar code paths:

Traceback (most recent call last):
  File "/usr/bin/dxf2gcode", line 1198, in <module>
    window.load()
  File "/usr/bin/dxf2gcode", line 844, in load
    self.valuesDXF = ReadDXF(self.filename)
  File "/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/importer.py", line 85, in __init__
    self.entities = self.Read_Entities(sections_pos)
  File "/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/importer.py", line 345, in Read_Entities
    sections[section_nr - 1].end - 1)
  File "/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/importer.py", line 360, in Get_Geo
    entitie_geo = self.get_geo_entitie(len(geos), name)
  File "/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/importer.py", line 419, in get_geo_entitie
    geo = GeoentLwPolyline(geo_nr, self)
  File "/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/geoent_lwpolyline.py", line 47, in __init__
    self.Read(caller)
  File "/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/geoent_lwpolyline.py", line 196, in Read
    self.geo.append(LineGeo(Ps=Ps, Pe=self.geo[0].Ps))
IndexError: list index out of range

Traceback (most recent call last):
  File "/usr/bin/dxf2gcode", line 1198, in <module>
    window.load()
  File "/usr/bin/dxf2gcode", line 844, in load
    self.valuesDXF = ReadDXF(self.filename)
  File "/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/importer.py", line 84, in __init__
    self.blocks = self.Read_Blocks(blocks_pos)
  File "/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/importer.py", line 332, in Read_Blocks
    blocks.Entities[-1].geo = self.Get_Geo(s, e)
  File "/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/importer.py", line 360, in Get_Geo
    entitie_geo = self.get_geo_entitie(len(geos), name)
  File "/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/importer.py", line 405, in get_geo_entitie
    geo = GeoentPolyline(geo_nr, self)
  File "/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/geoent_polyline.py", line 48, in __init__
    self.Read(caller)
  File "/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/geoent_polyline.py", line 215, in Read
    self.geo.append(LineGeo(Ps=Ps, Pe=self.geo[0].Ps))
IndexError: list index out of range

I attached two patches, that fixed both issues for me.

-- System Information:
Debian Release: buster/sid
  APT prefers testing
  APT policy: (500, 'testing'), (250, 'unstable'), (100, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.15.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE=C.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages dxf2gcode depends on:
ii  poppler-utils   0.62.0-2
ii  pstoedit        3.70-5+b1
ii  python3         3.6.4-1
ii  python3-opengl  3.1.0+dfsg-1
ii  python3-pyqt5   5.9.2+dfsg-1

dxf2gcode recommends no packages.

dxf2gcode suggests no packages.

-- no debconf information
-------------- next part --------------
--- a/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/geoent_polyline.py	2018-03-27 12:40:30.372009282 +0200
+++ b/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/geoent_polyline.py	2018-03-27 12:40:33.796011445 +0200
@@ -209,7 +209,7 @@
                 Ps = Pe
 
         # It is a closed polyline
-        if PolyLineFlag == 1:
+        if PolyLineFlag == 1 and len(self.geo) > 0:
             # print("sollten ?bereinstimmen: %s, %s" %(Ps,Pe))
             if next_bulge == 0:
                 self.geo.append(LineGeo(Ps=Ps, Pe=self.geo[0].Ps))
-------------- next part --------------
--- a/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/geoent_lwpolyline.py	2018-03-27 12:42:15.128038514 +0200
+++ b/usr/lib/python3/dist-packages/dxf2gcode/dxfimport/geoent_lwpolyline.py	2018-03-27 12:42:19.916038148 +0200
@@ -188,7 +188,7 @@
             next_bulge = bulge
             Ps = Pe
 
-        if LWPLClosed == 1 or LWPLClosed == 129:
+        if (LWPLClosed == 1 or LWPLClosed == 129) and len(self.geo) > 0:
             # print("sollten ?bereinstimmen: %s, %s" %(Ps,Pe))
             if next_bulge:
                 self.geo.append(self.bulge2arc(Ps, self.geo[0].Ps, next_bulge))


More information about the debian-science-maintainers mailing list