diff options
author | Jules Maselbas <jules.maselbas@grenoble-inp.org> | 2018-06-27 17:08:30 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2018-06-30 20:51:46 +0200 |
commit | 29f341da7cf32888f45005e08de202d9a372d972 (patch) | |
tree | 920410155c668968d28c1a6a62953c827ff27bb8 /x.c | |
parent | dc3b5babf1f8639a0d65cd347fc7879ac0461012 (diff) | |
download | st-patched-29f341da7cf32888f45005e08de202d9a372d972.tar.bz2 st-patched-29f341da7cf32888f45005e08de202d9a372d972.tar.xz st-patched-29f341da7cf32888f45005e08de202d9a372d972.zip |
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.
Diffstat (limited to 'x.c')
-rw-r--r-- | x.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -672,6 +672,8 @@ cresize(int width, int height) | |||
672 | 672 | ||
673 | col = (win.w - 2 * borderpx) / win.cw; | 673 | col = (win.w - 2 * borderpx) / win.cw; |
674 | row = (win.h - 2 * borderpx) / win.ch; | 674 | row = (win.h - 2 * borderpx) / win.ch; |
675 | col = MAX(1, col); | ||
676 | row = MAX(1, row); | ||
675 | 677 | ||
676 | tresize(col, row); | 678 | tresize(col, row); |
677 | xresize(col, row); | 679 | xresize(col, row); |
@@ -681,8 +683,8 @@ cresize(int width, int height) | |||
681 | void | 683 | void |
682 | xresize(int col, int row) | 684 | xresize(int col, int row) |
683 | { | 685 | { |
684 | win.tw = MAX(1, col * win.cw); | 686 | win.tw = col * win.cw; |
685 | win.th = MAX(1, row * win.ch); | 687 | win.th = row * win.ch; |
686 | 688 | ||
687 | XFreePixmap(xw.dpy, xw.buf); | 689 | XFreePixmap(xw.dpy, xw.buf); |
688 | xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, | 690 | xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, |
@@ -788,15 +790,17 @@ xhints(void) | |||
788 | 790 | ||
789 | sizeh = XAllocSizeHints(); | 791 | sizeh = XAllocSizeHints(); |
790 | 792 | ||
791 | sizeh->flags = PSize | PResizeInc | PBaseSize; | 793 | sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize; |
792 | sizeh->height = win.h; | 794 | sizeh->height = win.h; |
793 | sizeh->width = win.w; | 795 | sizeh->width = win.w; |
794 | sizeh->height_inc = win.ch; | 796 | sizeh->height_inc = win.ch; |
795 | sizeh->width_inc = win.cw; | 797 | sizeh->width_inc = win.cw; |
796 | sizeh->base_height = 2 * borderpx; | 798 | sizeh->base_height = 2 * borderpx; |
797 | sizeh->base_width = 2 * borderpx; | 799 | sizeh->base_width = 2 * borderpx; |
800 | sizeh->min_height = win.ch + 2 * borderpx; | ||
801 | sizeh->min_width = win.cw + 2 * borderpx; | ||
798 | if (xw.isfixed) { | 802 | if (xw.isfixed) { |
799 | sizeh->flags |= PMaxSize | PMinSize; | 803 | sizeh->flags |= PMaxSize; |
800 | sizeh->min_width = sizeh->max_width = win.w; | 804 | sizeh->min_width = sizeh->max_width = win.w; |
801 | sizeh->min_height = sizeh->max_height = win.h; | 805 | sizeh->min_height = sizeh->max_height = win.h; |
802 | } | 806 | } |