1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0022774: Memory leak in OSD_FontMgr::InitFontDataBase() method

This commit is contained in:
EPV 2011-12-23 06:31:56 +00:00 committed by bugmaster
parent 445f326751
commit a6535b1d3f

View File

@ -14,6 +14,7 @@
# include <X11/Xlib.h> # include <X11/Xlib.h>
#endif //WNT #endif //WNT
#include <OSD_Environment.hxx>
#include <NCollection_List.hxx> #include <NCollection_List.hxx>
#include <TCollection_HAsciiString.hxx> #include <TCollection_HAsciiString.hxx>
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
@ -106,7 +107,6 @@ OSD_FontMgr::OSD_FontMgr() {
} }
void OSD_FontMgr::InitFontDataBase() { void OSD_FontMgr::InitFontDataBase() {
MyListOfFonts.Clear(); MyListOfFonts.Clear();
@ -114,25 +114,16 @@ void OSD_FontMgr::InitFontDataBase() {
#ifdef WNT #ifdef WNT
//detect font directory //detect font directory
Standard_Character* windir_var; OSD_Environment env("windir");
Standard_Size req_size; TCollection_AsciiString windir_str = env.Value();
req_size = strlen( getenv("windir") ); if ( windir_str.IsEmpty() )
{
windir_var = new Standard_Character[req_size + 1];
strcpy( windir_var, getenv("windir") );
Standard_Character *font_dir = new Standard_Character[ req_size + strlen("\\Fonts\\") + 1 ] ;
if( !strcpy( font_dir, windir_var ) )
return; return;
if( !strcat( font_dir, "\\Fonts\\" ) ) }
return ; Handle(TCollection_HAsciiString) HFontDir = new TCollection_HAsciiString( windir_str );
HFontDir->AssignCat( "\\Fonts\\" );
Handle(TCollection_HAsciiString) HFontDir = new TCollection_HAsciiString(font_dir);
#ifdef TRACE #ifdef TRACE
cout << "System font directory: " << font_dir << "\n"; cout << "System font directory: " << HFontDir->ToCString() << "\n";
#endif TRACE #endif TRACE
//read registry //read registry
@ -200,7 +191,6 @@ void OSD_FontMgr::InitFontDataBase() {
if ( strchr( (Standard_Character*)buf_data, '\\' ) == NULL ) { if ( strchr( (Standard_Character*)buf_data, '\\' ) == NULL ) {
file_path->Insert( 1, HFontDir ); file_path->Insert( 1, HFontDir );
} }
Handle(TCollection_HAsciiString) HFontDir = new TCollection_HAsciiString(font_dir);
if( ( ( file_path->Search(".ttf") > 0 ) || ( file_path->Search(".TTF") > 0 ) || if( ( ( file_path->Search(".ttf") > 0 ) || ( file_path->Search(".TTF") > 0 ) ||
( file_path->Search(".otf") > 0 ) || ( file_path->Search(".OTF") > 0 ) || ( file_path->Search(".otf") > 0 ) || ( file_path->Search(".OTF") > 0 ) ||