Opened 15 years ago

#2951 new defect

Memory leaks reported by cppcheck utility

Reported by: rouault Owned by: sdlime
Priority: normal Milestone:
Component: MapServer C Library Version: svn-trunk (development)
Severity: normal Keywords:
Cc:

Description

When using cppcheck on svn trunk head (r8818), we get the following warnings. Most of them are related to memory leaks in error code paths :

$  cppcheck --quiet --all --force --style .
[./epplib.c:366]: (style) Warning - using char variable as array index
/mapserver.svn/mapserver
[./mapagg.h:227]: (style) Member variable not initialized in the constructor 'polygon_adaptor::oy'
[./mapagg.h:227]: (style) Member variable not initialized in the constructor 'polygon_adaptor::ox'
[./mapagg.cpp:886]: (style) C-style pointer casting
[./mapagg.cpp:2266]: (style) C-style pointer casting
[./mapcontext.c:1997]: (error) Memory leak: pszStyle
[./mapcontext.c:1566]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapcontext.c:1736]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapcontext.c:1840]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapdraw.c:1086]: (all) Memory leak: colorbuffer
[./mapdraw.c:1086]: (all) Memory leak: mindistancebuffer
[./mapfile.c:117]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapfile.c:5048]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapgdal.c:244]: (error) Memory leak: pabyAlphaLine
[./mapgml.c:826]: (error) Memory leak: itemList
[./mapgml.c:1204]: (error) Memory leak: itemtab
[./maphash.c:143]: (error) Memory leak: tp
[./maphash.c:111]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./maplexer.c:371]: (style) struct or union member 'yy_trans_info::yy_verify' is never used
[./maplexer.c:372]: (style) struct or union member 'yy_trans_info::yy_nxt' is never used
[./mapmssql2008.c:362]: (all) Memory leak: layerinfo
[./mapmygis.c:403]: (error) Memory leak: DB_HOST
[./mapmygis.c:403]: (error) Memory leak: DB_USER
[./mapmygis.c:403]: (error) Memory leak: DB_PASSWD
[./mapmygis.c:403]: (error) Memory leak: DB_DATABASE
[./mapmygis.c:429]: (error) Memory leak: DB_DATATYPE
[./mapmygis.c:720]: (error) Memory leak: query_str
[./mapmygis.c:1669]: (error) Memory leak: query_str
[./mapmygis.c:162]: (style) struct or union member 'ms_MYGIS_layer_info_t::query2' is never used
[./mapmygis.c:165]: (style) struct or union member 'ms_MYGIS_layer_info_t::user_srid' is never used
[./mapogcfilter.c:433]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapogcfilter.c:1036]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapogcfilter.c:1203]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapogcfilter.c:726]: (all) Memory leak: panResults
[./mapogcfilter.c:3041]: (error) Memory leak: pszBuffer
[./mapogcsld.c:5084]: (error) Memory leak: pszFinalExpression
[./mapogcsld.c:1130]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapogcsld.c:3507]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapogcsos.c:2697]: (all) Memory leak: pszProcedureId
[./mapogcsos.c:2785]: (error) Memory leak: paramsObj
[./mapogcsos.c:521]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapogcsos.c:525]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapogr.cpp:897]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./maporaclespatial.c:1551]: (all) Memory leak: layerinfo
[./maporaclespatial.c:1551]: (all) Memory leak: dthand
[./mapparser.c:203]: (style) struct or union member 'yyalloc::yyss' is never used
[./mapparser.c:204]: (style) struct or union member 'yyalloc::yyvs' is never used
[./mappdf.c:179]: (error) Memory leak: oImage
[./mappdf.c:179]: (all) Memory leak: driver
[./mappdf.c:1478]: (all) Memory leak: driver
[./mappdf.c:132]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mappdf.c:179]: (error) Memory leak: driver
[./mappdf.c:300]: (error) Overlapping data buffer optlist
[./mappdf.c:301]: (error) Overlapping data buffer optlist
[./mappostgis.c:454]: (all) Memory leak: schema
[./mappostgis.c:454]: (all) Memory leak: table
[./mappostgis.c:1094]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mappostgis.c:1116]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mappostgis.c:1117]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mappostgis.c:1192]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mappostgis.c:1193]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mappostgis.c:1283]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mappostgis.c:1284]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mappostgis.c:1285]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapprimitive.c:1750]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapquery.c:332]: (error) Memory leak: old_filterstring
[./mapquery.c:332]: (all) Memory leak: old_filteritem
[./mapresample.c:835]: (error) Memory leak: psPTInfo
[./maprgbapng.c:853]: (all style) Warning: Division with signed and unsigned operators
[./maprgbapng.c:857]: (all style) Warning: Division with signed and unsigned operators
[./mapscript/php3/php_mapscript.c:5052]: (error) Deallocating a deallocated pointer: panIndexes
[./mapsde.c:248]: (all) Memory leak: column_name
[./mapsde.c:260]: (error) Memory leak: full_column_name
[./mapsde.c:528]: (error) Memory leak: part_offsets
[./mapsde.c:528]: (error) Memory leak: subpart_offsets
[./mapsde.c:962]: (error) Memory leak: full_filter
[./mapsde.c:1171]: (error) Memory leak: sde
[./mapsde.c:1146]: (error) Memory leak: poolinfo
[./mapsde.c:1963]: (error) Memory leak: all_itemdefs
[./mapserv.c:150]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapserv.c:151]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapserv.c:152]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapserv.c:153]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapserv.c:154]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapserv.c:1792]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapserv.c:1793]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapserv.c:1794]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapserv.c:1795]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapserv.c:1796]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapshape.c:471]: (error) Memory leak: pszFullname
[./mapshape.c:471]: (error) Resource leak: fpSHP
[./mapshape.c:2435]: (error) Memory leak: shpfile
[./mapsvg.c:173]: (error) Memory leak: image
[./mapsvg.c:1705]: (error) Resource leak: stream
[./mapswf.c:1329]: (error) Memory leak: panIndex
[./mapswf.c:3449]: (all) Memory leak: driver
[./maptemplate.c:733]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./maptemplate.c:739]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./maptemplate.c:2546]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./maptemplate.c:2592]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./maptemplate.c:2618]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./maptemplate.c:2664]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./maptemplate.c:2708]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./maptemplate.c:2731]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./maptemplate.c:2772]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./maptime.c:232]: (all) Memory leak: limitedpatternindice
[./maptree.c:548]: (all) Memory leak: node
[./maputil.c:388]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./maputil.c:394]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapwcs.c:810]: (all) Memory leak: updatesequence
[./mapwcs.c:1209]: (error) Memory leak: updatesequence
[./mapwcs.c:81]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapwfs.c:498]: (all) Memory leak: updatesequence
[./mapwfs.c:350]: (error) Memory leak: wmtver
[./mapwfs.c:679]: (error) Memory leak: element_tab
[./mapwfs.c:1680]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapwfs.c:1374]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./mapwfs11.c:182]: (error) Memory leak: value
[./mapwms.c:422]: (error) Memory leak: sldenabled
[./mapwms.c:457]: (error) Memory leak: layerOrder
[./mapwms.c:1951]: (error) Memory leak: sldenabled
[./mapwms.c:3223]: (error) Memory leak: sldenabled
[./mapwmslayer.c:969]: (error) Memory leak: pszProxyUsername
[./mapwmslayer.c:1126]: (error) Memory leak: pszHttpAuthUsername
[./mapwmslayer.c:594]: (style) Redundant condition. It is safe to deallocate a NULL pointer
[./shp2img.c:323]: (all) Memory leak: invalid_layer
[./shp2pdf.c:205]: (all) Memory leak: invalid_layer

Attachments (1)

memleaks.diff (5.6 KB ) - added by bretlambert 14 years ago.
Potential fixes for some of the identified memory leaks

Download all attachments as: .zip

Change History (1)

by bretlambert, 14 years ago

Attachment: memleaks.diff added

Potential fixes for some of the identified memory leaks

Note: See TracTickets for help on using tickets.