[qwaq] Add a guard to formatLine

I got really weird error (invalid panel passed to top_panel) when there
was no such call, so I guess there was some memory corruption.
formatLine is the only suspect, but when I put in the guard, the error
wasn't reproduced (just scrolling through qwaq's makefile in a big
window).
This commit is contained in:
Bill Currie 2020-03-23 23:18:02 +09:00
parent 52722b73c1
commit 8707ac0d57
1 changed files with 6 additions and 0 deletions

View File

@ -456,6 +456,8 @@ formatLine (txtbuffer_t *buffer, unsigned linePtr, unsigned xpos,
int col;
byte c = 0;
int count;
int *startdst = dst;
int startlen = length;
while (pos < xpos && ptr < buffer->textSize) {
c = getChar (buffer, ptr);
@ -498,6 +500,10 @@ formatLine (txtbuffer_t *buffer, unsigned linePtr, unsigned xpos,
while (length-- > 0) {
*dst++ = col | ' ';
}
if (dst - startdst > startlen) {
Sys_Error ("formatLine wrote too much: %zd %u %d",
dst - startdst, startlen, length);
}
return ptr;
}