memory leaks in SLD parsing and application
Am using valgrind 2.2 on Linux (FC2) to debug some Python mapscript code.
My script uses the test mapfile at mapserver/tests/test.map and essentially
generates SLDs for the layers of this mapfile and then re-applys the SLDs
to the same layers. It's trivial, sure, but demonstrates some leaks.
==5321== 60 bytes in 3 blocks are definitely lost in loss record 52 of 88
==5321== at 0x1B904A80: malloc (vg_replace_malloc.c:131)
==5321== by 0x1C059498: FLTCreateFilterEncodingNode (mapogcfilter.c:1087)
==5321== by 0x1C0593C8: FLTParseFilterEncoding (mapogcfilter.c:989)
==5321== by 0x1C05C022: msSLDParseNamedLayer (mapogcsld.c:717)
==5321== by 0x1C05BBE5: msSLDParseSLD (mapogcsld.c:513)
==5321== by 0x1C05B587: msSLDApplySLD (mapogcsld.c:268)
==5321== by 0x1BFCD986: layerObj_applySLD (mapscript_wrap.c:1264)
==5321== by 0x1BFE9490: _wrap_layerObj_applySLD (mapscript_wrap.c:14770)
==5321== by 0x80EA40C: PyCFunction_Call (in /usr/bin/python)
==5321== by 0x805B3B6: PyObject_Call (in /usr/bin/python)
==5321== by 0x80AB92A: (within /usr/bin/python)
==5321== by 0x80A93C7: (within /usr/bin/python)
==5321==
==5321==
==5321== 80 bytes in 14 blocks are definitely lost in loss record 54 of 88
==5321== at 0x1B904A80: malloc (vg_replace_malloc.c:131)
==5321== by 0x1B9DA4EF: strdup (in /lib/tls/libc-2.3.3.so)
==5321== by 0x1C05AE57: FLTGetBinaryComparisonExpresssion (mapogcfilter.c:2347)
==5321== by 0x1C05A944: FLTGetMapserverExpression (mapogcfilter.c:2100)
==5321== by 0x1C05C061: msSLDParseNamedLayer (mapogcsld.c:732)
==5321== by 0x1C05BBE5: msSLDParseSLD (mapogcsld.c:513)
==5321== by 0x1C05B587: msSLDApplySLD (mapogcsld.c:268)
==5321== by 0x1BFCD986: layerObj_applySLD (mapscript_wrap.c:1264)
==5321== by 0x1BFE9490: _wrap_layerObj_applySLD (mapscript_wrap.c:14770)
==5321== by 0x80EA40C: PyCFunction_Call (in /usr/bin/python)
==5321== by 0x805B3B6: PyObject_Call (in /usr/bin/python)
==5321== by 0x80AB92A: (within /usr/bin/python)
==5321==
==5321==
==5321== 96 bytes in 6 blocks are definitely lost in loss record 55 of 88
==5321== at 0x1B9053FD: calloc (vg_replace_malloc.c:176)
==5321== by 0x1C1B3F5D: VSICalloc (in /usr/local/lib/libgdal.so.1.3.0)
==5321== by 0x1C1ADC57: CPLCalloc (in /usr/local/lib/libgdal.so.1.3.0)
==5321== by 0x1C1B169C: CPLCreateXMLNode (in /usr/local/lib/libgdal.so.1.3.0)
==5321== by 0x1C1B1988: CPLCloneXMLTree (in /usr/local/lib/libgdal.so.1.3.0)
==5321== by 0x1C05BFF1: msSLDParseNamedLayer (mapogcsld.c:705)
==5321== by 0x1C05BBE5: msSLDParseSLD (mapogcsld.c:513)
==5321== by 0x1C05B587: msSLDApplySLD (mapogcsld.c:268)
==5321== by 0x1BFCD986: layerObj_applySLD (mapscript_wrap.c:1264)
==5321== by 0x1BFE9490: _wrap_layerObj_applySLD (mapscript_wrap.c:14770)
==5321== by 0x80EA40C: PyCFunction_Call (in /usr/bin/python)
==5321== by 0x805B3B6: PyObject_Call (in /usr/bin/python)
==5321==
==5321==
...
==5321==
==5321== 2096 bytes in 4 blocks are definitely lost in loss record 76 of 88
==5321== at 0x1B904A80: malloc (vg_replace_malloc.c:131)
==5321== by 0x1C05BB53: msSLDParseSLD (mapogcsld.c:497)
==5321== by 0x1C05B587: msSLDApplySLD (mapogcsld.c:268)
==5321== by 0x1BFCD986: layerObj_applySLD (mapscript_wrap.c:1264)
==5321== by 0x1BFE9490: _wrap_layerObj_applySLD (mapscript_wrap.c:14770)
==5321== by 0x80EA40C: PyCFunction_Call (in /usr/bin/python)
==5321== by 0x805B3B6: PyObject_Call (in /usr/bin/python)
==5321== by 0x80AB92A: (within /usr/bin/python)
==5321== by 0x80A93C7: (within /usr/bin/python)
==5321== by 0x80A9B5D: PyEval_EvalCodeEx (in /usr/bin/python)
==5321== by 0x80AB34B: (within /usr/bin/python)
==5321== by 0x80AB199: (within /usr/bin/python)
Here is the code of the script:
-------------------------------
...
# Layers
for layer, style in styledlayers:
i = m.insertLayer(layer)
l = m.getLayer(i)
if style:
l.applySLD(style, l.name)
l.status = mapscript.MS_DEFAULT
# Render
return m.draw()