Opened 13 years ago

Closed 13 years ago

#1796 closed defect (fixed)

MDF Model: Fix Memory Leak

Reported by: gregboone Owned by: gregboone
Priority: high Milestone: 2.3
Component: Resource Service Version: 2.2.0
Severity: major Keywords: Memory
Cc: External ID:

Description

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.

Attachments (1)

UnicodeString_1796.patch (318 bytes ) - added by gregboone 13 years ago.
Patch to fix the Defect

Download all attachments as: .zip

Change History (2)

by gregboone, 13 years ago

Attachment: UnicodeString_1796.patch added

Patch to fix the Defect

comment:1 by tomfukushima, 13 years ago

Resolution: fixed
Status: newclosed

Applied patch... r6109

Note: See TracTickets for help on using tickets.