Skip to content

Commit c529fba

Browse files
committed
Fixed a couple of memory leaks
1 parent b17c5b9 commit c529fba

File tree

6 files changed

+21
-6
lines changed

6 files changed

+21
-6
lines changed

MUSHclient.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ BOOL CMUSHclientApp::InitInstance()
248248
// where we do file browsing from
249249
strcpy (file_browsing_dir, working_dir);
250250

251-
// bc_init_numbers();
251+
bc_init_numbers();
252252

253253

254254
// First free the string that was allocated by MFC in the startup
@@ -396,7 +396,7 @@ BOOL CMUSHclientApp::InitInstance()
396396

397397
// Set the debug-heap flag so that freed blocks are kept on the
398398
// linked list, to catch any inadvertent use of freed memory
399-
// SET_CRT_DEBUG_FIELD( _CRTDBG_DELAY_FREE_MEM_DF );
399+
SET_CRT_DEBUG_FIELD( _CRTDBG_DELAY_FREE_MEM_DF );
400400
SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF );
401401
// SET_CRT_DEBUG_FIELD( _CRTDBG_CHECK_ALWAYS_DF );
402402
// speed warning: see: _ASSERTE( _CrtCheckMemory( ) );
@@ -1223,7 +1223,7 @@ int CMUSHclientApp::ExitInstance()
12231223

12241224
THEMEGLUE_FREE ();
12251225

1226-
// bc_free_numbers (); // free zero, one, two
1226+
bc_free_numbers (); // free zero, one, two
12271227

12281228
// free the resources DLL
12291229
FreeLibrary (m_hInstDLL);

TextView.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ CTextView::CTextView()
5959
CTextView::~CTextView()
6060
{
6161
delete m_font;
62+
if (m_backbr)
63+
m_backbr->DeleteObject ();
6264
delete m_backbr;
6365
}
6466

@@ -186,6 +188,10 @@ void CTextView::OnInitialUpdate()
186188

187189
SetTheFont ();
188190

191+
if (m_backbr)
192+
m_backbr->DeleteObject ();
193+
delete m_backbr;
194+
189195
m_backbr = new CBrush (pDoc->m_backColour);
190196
m_backcolour = pDoc->m_backColour;
191197

@@ -757,6 +763,8 @@ CRect rect;
757763
// recreate background colour if necessary
758764
if (m_backcolour != pDoc->m_backColour)
759765
{
766+
if (m_backbr)
767+
m_backbr->DeleteObject ();
760768
delete m_backbr;
761769
m_backbr = new CBrush (pDoc->m_backColour);
762770
m_backcolour = pDoc->m_backColour;

doc_construct.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ int i;
643643
delete dbit->second; // now delete memory used by it
644644
}
645645

646-
}
646+
} // end of CMUSHclientDoc::~CMUSHclientDoc
647647

648648

649649
BOOL CMUSHclientDoc::OnNewDocument()

resource.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@
15621562
#ifdef APSTUDIO_INVOKED
15631563
#ifndef APSTUDIO_READONLY_SYMBOLS
15641564
#define _APS_3D_CONTROLS 1
1565-
#define _APS_NEXT_RESOURCE_VALUE 363
1565+
#define _APS_NEXT_RESOURCE_VALUE 364
15661566
#define _APS_NEXT_COMMAND_VALUE 33054
15671567
#define _APS_NEXT_CONTROL_VALUE 2897
15681568
#define _APS_NEXT_SYMED_VALUE 312

scripting/lbc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static const luaL_reg R[] =
274274

275275
LUALIB_API int luaopen_bc(lua_State *L)
276276
{
277-
bc_init_numbers();
277+
// bc_init_numbers(); // done once in MUSHclient.cpp
278278
lua_pushliteral(L,MYNAME);
279279
luaL_newmetatable(L,MYTYPE);
280280
luaL_openlib(L,NULL,R,0);

sendvw.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ CSendView::CSendView()
265265

266266
CSendView::~CSendView()
267267
{
268+
if (m_backbr)
269+
m_backbr->DeleteObject ();
268270
delete m_backbr;
269271
}
270272

@@ -1127,6 +1129,8 @@ CRect rect;
11271129
// recreate background colour if necessary
11281130
if (m_backcolour != pDoc->m_input_background_colour)
11291131
{
1132+
if (m_backbr)
1133+
m_backbr->DeleteObject ();
11301134
delete m_backbr;
11311135
m_backbr = new CBrush (pDoc->m_input_background_colour);
11321136
m_backcolour = pDoc->m_input_background_colour;
@@ -1207,6 +1211,9 @@ void CSendView::OnInitialUpdate()
12071211

12081212
m_owner_frame->FixUpSplitterBar ();
12091213

1214+
if (m_backbr)
1215+
m_backbr->DeleteObject ();
1216+
delete m_backbr;
12101217
m_backbr = new CBrush (pDoc->m_input_background_colour);
12111218
m_backcolour = pDoc->m_input_background_colour;
12121219

0 commit comments

Comments
 (0)