[hackers] [st] Fix crash on resize || Jules Maselbas

From: <git_AT_suckless.org>
Date: Sat, 30 Jun 2018 20:54:12 +0200 (CEST)

commit 29f341da7cf32888f45005e08de202d9a372d972
Author: Jules Maselbas <jules.maselbas_AT_grenoble-inp.org>
AuthorDate: Wed Jun 27 17:08:30 2018 +0200
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Sat Jun 30 20:51:46 2018 +0200

    Fix crash on resize
    
    Prevent to realloc xw.specbuc with a negative number of col.
    Add proper hints for the minimal size, for one character.

diff --git a/x.c b/x.c
index c0bd890..00cb6b1 100644
--- a/x.c
+++ b/x.c
_AT_@ -672,6 +672,8 @@ cresize(int width, int height)
 
         col = (win.w - 2 * borderpx) / win.cw;
         row = (win.h - 2 * borderpx) / win.ch;
+ col = MAX(1, col);
+ row = MAX(1, row);
 
         tresize(col, row);
         xresize(col, row);
_AT_@ -681,8 +683,8 @@ cresize(int width, int height)
 void
 xresize(int col, int row)
 {
- win.tw = MAX(1, col * win.cw);
- win.th = MAX(1, row * win.ch);
+ win.tw = col * win.cw;
+ win.th = row * win.ch;
 
         XFreePixmap(xw.dpy, xw.buf);
         xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
_AT_@ -788,15 +790,17 @@ xhints(void)
 
         sizeh = XAllocSizeHints();
 
- sizeh->flags = PSize | PResizeInc | PBaseSize;
+ sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize;
         sizeh->height = win.h;
         sizeh->width = win.w;
         sizeh->height_inc = win.ch;
         sizeh->width_inc = win.cw;
         sizeh->base_height = 2 * borderpx;
         sizeh->base_width = 2 * borderpx;
+ sizeh->min_height = win.ch + 2 * borderpx;
+ sizeh->min_width = win.cw + 2 * borderpx;
         if (xw.isfixed) {
- sizeh->flags |= PMaxSize | PMinSize;
+ sizeh->flags |= PMaxSize;
                 sizeh->min_width = sizeh->max_width = win.w;
                 sizeh->min_height = sizeh->max_height = win.h;
         }
Received on Sat Jun 30 2018 - 20:54:12 CEST

This archive was generated by hypermail 2.3.0 : Sat Jun 30 2018 - 21:00:26 CEST