[mapserver-dev] WFS Layer error (#3136)

Jim Klassen Jim.Klassen at ci.stpaul.mn.us
Mon Sep 28 16:52:08 EDT 2009


I am seeing an seg-fault when trying to access a WFS layer in mapserver (CONNECTIONTYPE WFS).

The seg-fault is at msOGRFileGetItems because psInfo (same as layerinfo) is NULL.

(gdb) bt
#0  0x00000000004679f2 in msOGRFileGetItems (layer=0x70d450, psInfo=0x0) at mapogr.cpp:1651
#1  0x000000000046c157 in msOGRLayerGetItems (layer=0x70d450) at mapogr.cpp:2275
#2  0x00000000004e3fa3 in msWFSLayerGetItems (layer=0x70d450) at mapwfslayer.c:919
#3  0x000000000046cd7c in msLayerGetItems (layer=0x70d450) at maplayer.c:246
#4  0x000000000046d27e in msLayerWhichItems (layer=0x70d450, get_all=0, metadata=0x0) at maplayer.c:385
#5  0x0000000000480c65 in msDrawVectorLayer (map=0x6f3fb0, layer=0x70d450, image=0x70d3f0) at mapdraw.c:929
#6  0x0000000000480778 in msDrawLayer (map=0x6f3fb0, layer=0x70d450, image=0x70d3f0) at mapdraw.c:812
#7  0x000000000047f647 in msDrawMap (map=0x6f3fb0, querymap=0) at mapdraw.c:458
#8  0x00000000004147f3 in main (argc=2, argv=0x7fffdf89daa8) at mapserv.c:1414

layer->layerinfo is NULL because the OGR layer was never opened.
The OGR layer was never opened because msWFSLayerOpen checks if layer->wfslayerinfo is NULL and if it isn't assumes the layer is fully initialized. But this isn't the case because msPrepareWFSLayerRequest is pre-opening the layer thus setting up layer->wfslayerinfo but doesn't call msWFSLayerWhichShapes to initialize the OGR layer.

My fix: Add a NULL pointer check to msOGRFileGetItems. Add a check to msWFSOpenLayer to see if layer->layerinfo is set when layer->wfslayerinfo is set. If layerinfo isn't set it calls msWFSWhichShapes to setup the OGR layer, otherwise it does nothing (as before.)

I created ticket #3136 for this.




More information about the mapserver-dev mailing list