WINTERMUTE: Don't crop UIEdit strings to negative sizes

If _maxLength was -1, we would end up with a 0-size allocation,
and a write that starts right before it, which gives odd results.
This commit is contained in:
Einar Johan Trøan Sømåen 2016-10-07 00:18:15 +02:00
parent b2dcd1bb1e
commit 1eca88cb39

View File

@ -899,7 +899,7 @@ int UIEdit::deleteChars(int start, int end) {
//////////////////////////////////////////////////////////////////////////
int UIEdit::insertChars(int pos, const byte *chars, int num) {
if ((int)strlen(_text) + num > _maxLength) {
if ((_maxLength != -1) && (int)strlen(_text) + num > _maxLength) {
num -= (strlen(_text) + num - _maxLength);
}