From 54f4f31daedcf6fa3595c3ecac18e50c171903e3 Mon Sep 17 00:00:00 2001 From: Gregor Schneider Date: Sun, 12 Apr 2009 18:44:00 +0000 Subject: [PATCH] - Add parameter validity check to GetTextFaceA (same as in GetTextFaceW) svn path=/trunk/; revision=40473 --- reactos/dll/win32/gdi32/objects/text.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/reactos/dll/win32/gdi32/objects/text.c b/reactos/dll/win32/gdi32/objects/text.c index d26c7e63cb6..93896d45f5c 100644 --- a/reactos/dll/win32/gdi32/objects/text.c +++ b/reactos/dll/win32/gdi32/objects/text.c @@ -383,8 +383,19 @@ int WINAPI GetTextFaceA( HDC hdc, INT count, LPSTR name ) { - INT res = GetTextFaceW(hdc, 0, NULL); - LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, res * 2 ); + INT res; + LPWSTR nameW; + + /* Validate parameters */ + if (name && count <= 0) + { + /* Set last error and return failure */ + GdiSetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + res = GetTextFaceW(hdc, 0, NULL); + nameW = HeapAlloc( GetProcessHeap(), 0, res * 2 ); GetTextFaceW( hdc, res, nameW ); if (name)