[hackers] [sent] fix several number overflow issues || Markus Teich

From: <git_AT_suckless.org>
Date: Tue, 17 Nov 2015 00:17:35 +0100 (CET)

commit 84734c73e82b8b30e2eef82c192a53010fb2d35f
Author: Markus Teich <markus.teich_AT_stusta.mhn.de>
AuthorDate: Tue Nov 17 00:19:39 2015 +0100
Commit: Markus Teich <markus.teich_AT_stusta.mhn.de>
CommitDate: Tue Nov 17 00:19:39 2015 +0100

    fix several number overflow issues

diff --git a/sent.c b/sent.c
index c4696be..6fd288b 100644
--- a/sent.c
+++ b/sent.c
_AT_@ -318,7 +318,7 @@ void pngdraw(Image *img)
 
 void getfontsize(Slide *s, unsigned int *width, unsigned int *height)
 {
- size_t i, j;
+ int i, j;
         unsigned int curw, imax;
         float lfac = linespacing * (s->linecount - 1) + 1;
 
_AT_@ -326,7 +326,7 @@ void getfontsize(Slide *s, unsigned int *width, unsigned int *height)
         for (j = NUMFONTSCALES - 1; j >= 0; j--)
                 if (fonts[j]->h * lfac <= xw.uh)
                         break;
- drw_setfontset(d, fonts[j]);
+ drw_setfontset(d, fonts[++j]);
 
         /* fit width */
         *width = 0;
_AT_@ -334,7 +334,7 @@ void getfontsize(Slide *s, unsigned int *width, unsigned int *height)
                 curw = drw_fontset_getwidth(d, s->lines[i]);
                 if (curw >= *width)
                         imax = i;
- while (j >= 0 && curw > xw.uw) {
+ while (j > 0 && curw > xw.uw) {
                         drw_setfontset(d, fonts[--j]);
                         curw = drw_fontset_getwidth(d, s->lines[i]);
                 }
Received on Tue Nov 17 2015 - 00:17:35 CET

This archive was generated by hypermail 2.3.0 : Tue Nov 17 2015 - 00:24:13 CET