Skip to content

Commit 9fa44f0

Browse files
committed
Merge pull request #22 from noshbar/L1
Fix potential memory leak in win32/console.c
2 parents 44510dc + 5d45545 commit 9fa44f0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

contrib/win32/win32compat/console.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,13 @@ SCREEN_HANDLE ConSaveScreenHandle( SCREEN_HANDLE hScreen )
16271627
}
16281628

16291629
if ( !pScreenRec->pScreenBuf )
1630+
{
1631+
// if we allocated a screen within this scope, free it before returning
1632+
if ( pScreenRec != (PSCREEN_RECORD)hScreen ) {
1633+
free(pScreenRec);
1634+
}
16301635
return NULL;
1636+
}
16311637

16321638
result = ReadConsoleOutput( hConsole, // handle of a console screen buffer
16331639
(PCHAR_INFO)(pScreenRec->pScreenBuf), // address of buffer that receives data

0 commit comments

Comments
 (0)