forked from mirror/OpenTTD
(svn r4301) - Fix: the maxlength parameter of Textbuf is supposed to be the size of the buffer (so length of string + '\0'), but in the code it was a mix of both. It didn't cause any problems though, only an occasionaly one-less character than allowed. (thanks Tron for noticing)
This commit is contained in:
7
win32.c
7
win32.c
@@ -1228,14 +1228,13 @@ bool InsertTextBufferClipboard(Textbuf *tb)
|
||||
data = GlobalLock(cbuf); // clipboard data
|
||||
dataptr = data;
|
||||
|
||||
for (; IsValidAsciiChar(*dataptr) && (tb->length + length) < tb->maxlength - 1 &&
|
||||
for (; IsValidAsciiChar(*dataptr) && (tb->length + length) < (tb->maxlength - 1) &&
|
||||
(tb->maxwidth == 0 || width + tb->width + GetCharacterWidth((byte)*dataptr) <= tb->maxwidth); dataptr++) {
|
||||
width += GetCharacterWidth((byte)*dataptr);
|
||||
length++;
|
||||
}
|
||||
|
||||
if (length == 0)
|
||||
return false;
|
||||
if (length == 0) return false;
|
||||
|
||||
memmove(tb->buf + tb->caretpos + length, tb->buf + tb->caretpos, tb->length - tb->caretpos);
|
||||
memcpy(tb->buf + tb->caretpos, data, length);
|
||||
@@ -1244,7 +1243,7 @@ bool InsertTextBufferClipboard(Textbuf *tb)
|
||||
|
||||
tb->length += length;
|
||||
tb->caretpos += length;
|
||||
tb->buf[tb->length + 1] = '\0'; // terminating zero
|
||||
tb->buf[tb->length] = '\0'; // terminating zero
|
||||
|
||||
GlobalUnlock(cbuf);
|
||||
CloseClipboard();
|
||||
|
Reference in New Issue
Block a user