From 78bd8c874aa860b55529d38c6357ad160279b091 Mon Sep 17 00:00:00 2001 From: John Peterson Date: Sat, 29 Aug 2009 08:48:16 +0000 Subject: [PATCH] GUI: Crash fix git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4095 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/ConsoleListener.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/Core/Common/Src/ConsoleListener.cpp b/Source/Core/Common/Src/ConsoleListener.cpp index 3021f455f2..163bcdefb0 100644 --- a/Source/Core/Common/Src/ConsoleListener.cpp +++ b/Source/Core/Common/Src/ConsoleListener.cpp @@ -130,7 +130,8 @@ void ConsoleListener::LetterSpace(int Width, int Height) void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool Resize) { #ifdef _WIN32 - hConsole = GetStdHandle(STD_OUTPUT_HANDLE); + // Check size + if (Width < 8 || Height < 12) return; // Get console info CONSOLE_SCREEN_BUFFER_INFO ConInfo; @@ -140,9 +141,11 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool int LHeight = floor((float)(Height / 12)); int LBufHeight = floor((float)(MAX_BYTES / (LWidth + 1))); - // Read the current text - char Str[MAX_BYTES]; + // Check size DWORD dwConSize = ConInfo.dwSize.X * ConInfo.dwSize.Y; + if (dwConSize > MAX_BYTES) return; + // Read the current text + char Str[MAX_BYTES]; DWORD cCharsRead = 0; COORD coordScreen = { 0, 0 }; ReadConsoleOutputCharacter(hConsole, Str, dwConSize, coordScreen, &cCharsRead);