Re: [dev] [st] crash on font resize (patch inside)

From: Nils Reuße <ml_AT_hxgn.net>
Date: Sun, 15 Feb 2015 09:59:07 +0100

On 14.02.2015 22:55, Nils Reuße wrote:
> hi folks,
>
> i found a bug in st (latest git):
>
> if you keep downsizing your fontsize until either xw.ch or xw.cw gets 0,
> st crashes, because there is an unchecked division in cresize. my patch
> fixes the problem, but i haven't checked for a better solution.
>
> nils
>
>
> diff --git a/st.c b/st.c
> index 1deb7bc..5403d29 100644
> --- a/st.c
> +++ b/st.c
> _AT_@ -3815,8 +3815,8 @@ cresize(int width, int height) {
> if(height != 0)
> xw.h = height;
>
> - col = (xw.w - 2 * borderpx) / xw.cw;
> - row = (xw.h - 2 * borderpx) / xw.ch;
> + col = (xw.w - 2 * borderpx) / (xw.cw ? xw.cw : 1);
> + row = (xw.h - 2 * borderpx) / (xw.ch ? xw.ch : 1);
>
> tresize(col, row);
> xresize(col, row);

This patch also does the job, and also prevents (gohufont, at least) to
disappear completely.

diff --git a/st.c b/st.c
index 1deb7bc..547ddc9 100644
--- a/st.c
+++ b/st.c
_AT_@ -2992,7 +2992,7 @@ xloadfonts(char *fontstr, double fontsize) {
         if(!pattern)
                 die("st: can't open font %s\n", fontstr);

- if(fontsize > 0) {
+ if(fontsize > 1) {
                 FcPatternDel(pattern, FC_PIXEL_SIZE);
                 FcPatternDel(pattern, FC_SIZE);
                 FcPatternAddDouble(pattern, FC_PIXEL_SIZE,
(double)fontsize);
Received on Sun Feb 15 2015 - 09:59:07 CET

This archive was generated by hypermail 2.3.0 : Sun Feb 15 2015 - 10:00:09 CET