Skip to content

Commit 55d8ed6

Browse files
committed
fix(memory): remove heap allocation in OnDestroy and store window position safely
Replaced the leaked `new tagRECT` allocation with a stack-allocated RECT in OnDestroy. The dialog's final on-screen position is now captured using a local RECT and saved without introducing a memory leak. This fixes a small resource leak and improves shutdown correctness without changing behavior.
1 parent e07a405 commit 55d8ed6

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

ColorCopDlg.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,14 +2077,12 @@ CString CColorCopDlg::GetTempFolder() {
20772077
}
20782078

20792079
void CColorCopDlg::OnDestroy() {
2080-
//
2081-
// The app is about to close, save the variables
2082-
// save the location
2083-
tagRECT *winSize = new tagRECT;
2084-
GetWindowRect(winSize);
2085-
WinLocX = winSize->left; // Store x, y
2086-
WinLocY = winSize->top; // in variables
2087-
2080+
// Capture and store the dialog’s last on-screen position so it can be
2081+
// restored the next time the application starts.
2082+
RECT winSize{};
2083+
GetWindowRect(&winSize);
2084+
WinLocX = winSize.left;
2085+
WinLocY = winSize.top;
20882086

20892087
// save the bitmap
20902088
CString strBMPFile = GetTempFolder();

0 commit comments

Comments
 (0)