[mapguide-trac] #1796: MDF Model: Fix Memory Leak

MapGuide Open Source trac_mapguide at osgeo.org
Thu Sep 1 14:19:38 EDT 2011


#1796: MDF Model: Fix Memory Leak
--------------------------------+-------------------------------------------
   Reporter:  gregboone         |       Owner:  gregboone
       Type:  defect            |      Status:  new      
   Priority:  high              |   Milestone:  2.3      
  Component:  Resource Service  |     Version:  2.2.0    
   Severity:  major             |    Keywords:  Memory   
External_id:                    |  
--------------------------------+-------------------------------------------
 Fix a memory leak in the following function:

 void UnicodeString::WideCharToMultiByte(const wchar_t* uniChar, string&
 str)
 {
 #ifdef _WIN32
     UTFCONVERT(UTF16,UTF8)
 #else
     UTFCONVERT(UTF32,UTF8)
 #endif
 }


 In the macro defintion

 UTFCONVERT(FROMCHARSET,TOCHARSET)

 If you look at the macro defintion, you will see that if any of the
 methods that call this macro pass in a non-empty 'str' as the target, then
 the contents of that string will be overwritten without having free’d the
 previous content. This is due to the fact that the 'targetStart' pointer
 is directly extracted from the 'str' output parameter here:

 targetStart = (TOCHARSET*) str.c_str();\

 This causes full layer definition XML string leak (which can be a big
 string) per layer per graphics generation.

-- 
Ticket URL: <http://trac.osgeo.org/mapguide/ticket/1796>
MapGuide Open Source <http://mapguide.osgeo.org/>
MapGuide Open Source Internals


More information about the mapguide-trac mailing list