forked from fte/fteqw
1
0
Fork 0

Fix an issue where reading out of the list could have been invalid.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3726 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2011-01-28 21:50:29 +00:00
parent b3278577bb
commit a8c4f7f4c1
1 changed files with 4 additions and 2 deletions

View File

@ -1023,9 +1023,9 @@ int Font_LineBreaks(conchar_t *start, conchar_t *end, int maxpixelwidth, int max
// scan the width of the line // scan the width of the line
for (px=0, l=0 ; px <= maxpixelwidth; ) for (px=0, l=0 ; px <= maxpixelwidth; )
{ {
if ((start[l]&CON_CHARMASK) == '\n' || (start+l >= end))
break;
l++; l++;
if (start+l >= end || (start[l-1]&CON_CHARMASK) == '\n')
break;
px = Font_CharEndCoord(px, start[l]); px = Font_CharEndCoord(px, start[l]);
} }
//if we did get to the end //if we did get to the end
@ -1048,6 +1048,8 @@ int Font_LineBreaks(conchar_t *start, conchar_t *end, int maxpixelwidth, int max
break; break;
start+=l; start+=l;
if (start == end)
break;
if ((*start&CON_CHARMASK) == '\n'||!l) if ((*start&CON_CHARMASK) == '\n'||!l)
start++; // skip the \n start++; // skip the \n