mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
[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:
parent
52722b73c1
commit
8707ac0d57
1 changed files with 6 additions and 0 deletions
|
@ -456,6 +456,8 @@ formatLine (txtbuffer_t *buffer, unsigned linePtr, unsigned xpos,
|
||||||
int col;
|
int col;
|
||||||
byte c = 0;
|
byte c = 0;
|
||||||
int count;
|
int count;
|
||||||
|
int *startdst = dst;
|
||||||
|
int startlen = length;
|
||||||
|
|
||||||
while (pos < xpos && ptr < buffer->textSize) {
|
while (pos < xpos && ptr < buffer->textSize) {
|
||||||
c = getChar (buffer, ptr);
|
c = getChar (buffer, ptr);
|
||||||
|
@ -498,6 +500,10 @@ formatLine (txtbuffer_t *buffer, unsigned linePtr, unsigned xpos,
|
||||||
while (length-- > 0) {
|
while (length-- > 0) {
|
||||||
*dst++ = col | ' ';
|
*dst++ = col | ' ';
|
||||||
}
|
}
|
||||||
|
if (dst - startdst > startlen) {
|
||||||
|
Sys_Error ("formatLine wrote too much: %zd %u %d",
|
||||||
|
dst - startdst, startlen, length);
|
||||||
|
}
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue