MapServer / MapServer-import

3 stars 2 forks source link

Adding empty shapeObj to ShapefileObj seg. faults instead of exception #1201

Open tbonfort opened 12 years ago

tbonfort commented 12 years ago

Reporter: tylermitchell@shaw.ca Date: 2005/02/02 - 05:42

I promise to report this bug under the condition that nobody asks me why I tried
this :)

Using Python MapScript like this, crashes Python.

>>> s1 = mapscript.shapeObj(0)
>>> sf1 = mapscript.shapefileObj("mypoints.shp",1)
>>> sf1.add(s1)
Segmentation fault

Shouldn't this throw an exception rather than an earth-quaking fault?
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2005/02/02 - 05:46

change component.
tbonfort commented 12 years ago

Author: sdlime Date: 2005/02/02 - 18:28

Perhaps we chould change the underlying C code. What do you think Sean? It's 
not uncommon at all to have functions require non-NULL input, but...

Steve
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2005/02/03 - 00:01

I just looked in mapprimitive.c and msInitShape().  The "lines" member of a
freshly initialized shapeObj is NULL.  When you try to add this to a shapefileObj
that could tries to access NULL as an array.  Boom!

All that needs to be done is to have msSHPWriteShape check shape->lines and if
NULL set an error and return immediately.
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2005/02/06 - 22:22

Fixed in CVS HEAD and branch-4-4.  Tyler, no mention of your usage.  Mum's the
word, man!