Opened 16 years ago

Closed 16 years ago

#2042 closed defect (fixed)

[PATCH] Fixes memory leaks in ili driver

Reported by: Even Rouault Owned by: pka
Priority: normal Milestone:
Component: OGR_SF Version: svn-trunk
Severity: normal Keywords: ili interlis
Cc: warmerdam

Description

The attached patch fixes memory leaks due to lack of XMLString::release after XMLString::transcode. It also replaces some "delete [] tmpCh" by XMLString::release

These memory leaks can be hit when running ogrinfo on a bad GPX file.

==32448== 67 bytes in 11 blocks are definitely lost in loss record 48 of 53
==32448==    at 0x4022B9C: operator new[](unsigned) (vg_replace_malloc.c:195)
==32448==    by 0x4923CAA: xercesc_2_7::ICULCPTranscoder::transcode(unsigned short const*) (in /usr/lib/libxerces-c.so.27.0)
==32448==    by 0x49F8410: xercesc_2_7::XMLString::transcode(unsigned short const*) (in /usr/lib/libxerces-c.so.27.0)
==32448==    by 0x43119CD: ILI2Handler::startElement(unsigned short const*, unsigned short const*, unsigned short const*, xercesc_2_7::Attributes const&) (ili2handler.cpp:102)
==32448==    by 0x49710E8: xercesc_2_7::SAX2XMLReaderImpl::startElement(xercesc_2_7::XMLElementDecl const&, unsigned, unsigned short const*, xercesc_2_7::RefVectorOf<xercesc_2_7::XMLAttr> const&, unsigned, bool, bool) (in /usr/lib/libxerces-c.so.27.0)
==32448==    by 0x4927AEF: xercesc_2_7::IGXMLScanner::scanStartTag(bool&) (in /usr/lib/libxerces-c.so.27.0)
==32448==    by 0x492D387: xercesc_2_7::IGXMLScanner::scanContent() (in /usr/lib/libxerces-c.so.27.0)
==32448==    by 0x492D4E5: xercesc_2_7::IGXMLScanner::scanDocument(xercesc_2_7::InputSource const&) (in /usr/lib/libxerces-c.so.27.0)
==32448==    by 0x49F6C1F: xercesc_2_7::XMLScanner::scanDocument(unsigned short const*) (in /usr/lib/libxerces-c.so.27.0)
==32448==    by 0x49F6CD6: xercesc_2_7::XMLScanner::scanDocument(char const*) (in /usr/lib/libxerces-c.so.27.0)
==32448==    by 0x497157F: xercesc_2_7::SAX2XMLReaderImpl::parse(char const*) (in /usr/lib/libxerces-c.so.27.0)
==32448==    by 0x43136D0: ILI2Reader::SaveClasses(char const*) (ili2reader.cpp:601)
==32448==    by 0x43A0D7B: OGRILI2DataSource::Open(char const*, int) (ogrili2datasource.cpp:158)
==32448==    by 0x43A129C: OGRILI2Driver::Open(char const*, int) (ogrili2driver.cpp:65)
==32448==    by 0x43C2725: OGRSFDriverRegistrar::Open(char const*, int, OGRSFDriver**) (ogrsfdriverregistrar.cpp:164)
==32448==    by 0x804965C: main (ogrinfo.cpp:149)
==32448==
==32448==
==32448== 156 bytes in 2 blocks are definitely lost in loss record 49 of 53
==32448==    at 0x4022B9C: operator new[](unsigned) (vg_replace_malloc.c:195)
==32448==    by 0x492377C: xercesc_2_7::ICULCPTranscoder::transcode(char const*) (in /usr/lib/libxerces-c.so.27.0)
==32448==    by 0x49F84BC: xercesc_2_7::XMLString::transcode(char const*) (in /usr/lib/libxerces-c.so.27.0)
==32448==    by 0x4312457: ILI2Reader::SetupParser() (ili2reader.cpp:571)
==32448==    by 0x431320E: ILI2Reader::ILI2Reader() (ili2reader.cpp:502)
==32448==    by 0x431327F: CreateILI2Reader() (ili2reader.cpp:681)
==32448==    by 0x43A0CDC: OGRILI2DataSource::Open(char const*, int) (ogrili2datasource.cpp:137)
==32448==    by 0x43A129C: OGRILI2Driver::Open(char const*, int) (ogrili2driver.cpp:65)
==32448==    by 0x43C2725: OGRSFDriverRegistrar::Open(char const*, int, OGRSFDriver**) (ogrsfdriverregistrar.cpp:164)
==32448==    by 0x804965C: main (ogrinfo.cpp:149)
==32448==
==32448==
==32448== 13,476 bytes in 114 blocks are possibly lost in loss record 51 of 53
==32448==    at 0x4022F0C: operator new(unsigned) (vg_replace_malloc.c:163)
==32448==    by 0x493FD25: xercesc_2_7::MemoryManagerImpl::allocate(unsigned) (in /usr/lib/libxerces-c.so.27.0)
==32448==    by 0x4A08CBA: xercesc_2_7::XMemory::operator new(unsigned) (in /usr/lib/libxerces-c.so.27.0)
==32448==    by 0x494F6D1: xercesc_2_7::XMLPlatformUtils::Initialize(char const*, char const*, xercesc_2_7::PanicHandler*, xercesc_2_7::MemoryManager*, bool) (in /usr/lib/libxerces-c.so.27.0)
==32448==    by 0x43124E3: ILI2Reader::SetupParser() (ili2reader.cpp:528)
==32448==    by 0x431320E: ILI2Reader::ILI2Reader() (ili2reader.cpp:502)
==32448==    by 0x431327F: CreateILI2Reader() (ili2reader.cpp:681)
==32448==    by 0x43A0CDC: OGRILI2DataSource::Open(char const*, int) (ogrili2datasource.cpp:137)
==32448==    by 0x43A129C: OGRILI2Driver::Open(char const*, int) (ogrili2driver.cpp:65)
==32448==    by 0x43C2725: OGRSFDriverRegistrar::Open(char const*, int, OGRSFDriver**) (ogrsfdriverregistrar.cpp:164)
==32448==    by 0x804965C: main (ogrinfo.cpp:149)

Attachments (1)

gdal_svn_trunk_ili2_memory_leak_fixes.patch (2.4 KB ) - added by Even Rouault 16 years ago.

Download all attachments as: .zip

Change History (3)

comment:1 by warmerdam, 16 years ago

Cc: warmerdam added
Owner: changed from warmerdam to pka

Pirmin,

Could you review and apply as appropriate?

comment:2 by pka, 16 years ago

Resolution: fixed
Status: newclosed

Patch applied in r13354.

Note: See TracTickets for help on using tickets.