From 331bf3d77c7e2d2c697b58d36a9e94e19eaf7682 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 15 Aug 2002 23:28:45 +0000 Subject: [PATCH] Avoid trouble in WM_GETTEXT if specified length is larger than the buffer (found by Carl Sopchak). --- controls/edit.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/controls/edit.c b/controls/edit.c index 68f66aba07..d148173b35 100644 --- a/controls/edit.c +++ b/controls/edit.c @@ -3962,15 +3962,14 @@ static INT EDIT_WM_GetText(EDITSTATE *es, INT count, LPARAM lParam, BOOL unicode if(unicode) { LPWSTR textW = (LPWSTR)lParam; - strncpyW(textW, es->text, count); - textW[count - 1] = 0; /* ensure 0 termination */ + lstrcpynW(textW, es->text, count); return strlenW(textW); } else { LPSTR textA = (LPSTR)lParam; - WideCharToMultiByte(CP_ACP, 0, es->text, -1, textA, count, NULL, NULL); - textA[count - 1] = 0; /* ensure 0 termination */ + if (!WideCharToMultiByte(CP_ACP, 0, es->text, -1, textA, count, NULL, NULL)) + textA[count - 1] = 0; /* ensure 0 termination */ return strlen(textA); } } -- 2.32.0.93.g670b81a890