修正:上个版本会访问非法内存导致段错误

This commit is contained in:
root 2022-09-03 13:10:20 +08:00
parent a82c282ea9
commit 0a87a84e67

View File

@ -299,11 +299,12 @@ static int render_unicode(FHandle fd, int *x, unsigned width, unsigned height, u
{
for (int j = 0; j < bbx[0]; ++j)
{
if( 0 <= i && i < (int)height && 0 <= j && j < (int)width )
int tx = cx+j, ty = cy-i;
if( 0 <= ty && ty < (int)height && 0 <= tx && tx < (int)width )
{
if( BIT_AT_POS(glyph, bbx[0] * i + j) )
{
SET_AT_POS( ram, PIX_IN_LINE(cx+j, cy-i, width) );
SET_AT_POS( ram, PIX_IN_LINE(tx, ty, width) );
}
}
}
@ -341,7 +342,7 @@ const char *acf_draw(int x, int y, unsigned width, unsigned height, unsigned max
next != NULL;
next = next_unicode(utf8_line, &unicode))
{
int error = render_unicode(font, &linex, maxwidth, height, unicode, option, localram);
int error = render_unicode(font, &linex, maxwidth, gblfont.height, unicode, option, localram);
if (error > 0 ) break;
else if(error < 0 ) error = render_unicode(font, &linex, maxwidth, height, '?', option, localram);