From a8c4f7f4c1353100fa886a006143dbebcc442ac3 Mon Sep 17 00:00:00 2001 From: Spoike Date: Fri, 28 Jan 2011 21:50:29 +0000 Subject: [PATCH] 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 --- engine/gl/gl_font.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engine/gl/gl_font.c b/engine/gl/gl_font.c index e4bd7ef69..4b550418f 100644 --- a/engine/gl/gl_font.c +++ b/engine/gl/gl_font.c @@ -1023,9 +1023,9 @@ int Font_LineBreaks(conchar_t *start, conchar_t *end, int maxpixelwidth, int max // scan the width of the line for (px=0, l=0 ; px <= maxpixelwidth; ) { - if ((start[l]&CON_CHARMASK) == '\n' || (start+l >= end)) - break; l++; + if (start+l >= end || (start[l-1]&CON_CHARMASK) == '\n') + break; px = Font_CharEndCoord(px, start[l]); } //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; start+=l; + if (start == end) + break; if ((*start&CON_CHARMASK) == '\n'||!l) start++; // skip the \n