Avoid trouble in WM_GETTEXT if specified length is larger than the
buffer (found by Carl Sopchak).
diff --git a/controls/edit.c b/controls/edit.c
index 68f66ab..d148173 100644
--- a/controls/edit.c
+++ b/controls/edit.c
@@ -3962,15 +3962,14 @@
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);
}
}