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.
Patch to fix the Defect