Opened 19 years ago

Closed 19 years ago

#1201 closed defect (fixed)

Adding empty shapeObj to ShapefileObj seg. faults instead of exception

Reported by: tylermitchell@… Owned by: sgillies@…
Priority: high Milestone:
Component: MapScript-SWIG Version: 4.4
Severity: normal Keywords:
Cc:

Description

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?

Change History (4)

comment:1 by sgillies@…, 19 years ago

Component: MapScriptMapScript-SWIG
Owner: changed from sdlime to sgillies@…
change component.

comment:2 by sdlime, 19 years ago

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

comment:3 by sgillies@…, 19 years ago

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.

comment:4 by sgillies@…, 19 years ago

Resolution: fixed
Status: newclosed
Fixed in CVS HEAD and branch-4-4.  Tyler, no mention of your usage.  Mum's the
word, man!
Note: See TracTickets for help on using tickets.