From 62371f0b21965e029644b7ef2fbd00c81d56c665 Mon Sep 17 00:00:00 2001 From: Jules Maselbas Date: Wed, 27 Jun 2018 17:08:30 +0200 Subject: [PATCH 1/5] 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. --- x.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/x.c b/x.c index 12dfc4c..ab59186 100644 --- a/x.c +++ b/x.c @@ -699,6 +699,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); @@ -708,8 +710,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, @@ -833,15 +835,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; } From 539e145e65c5f1bf773c2e9cae1315e54d8055ce Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sun, 4 Nov 2018 14:35:07 +0100 Subject: [PATCH 2/5] fix memory leak in xloadcols() reported by Avi Halachmi (:avih)" patch slightly changed by me. --- x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x.c b/x.c index ab59186..da5084b 100644 --- a/x.c +++ b/x.c @@ -760,12 +760,12 @@ xloadcols(void) static int loaded; Color *cp; - dc.collen = MAX(LEN(colorname), 256); - dc.col = xmalloc(dc.collen * sizeof(Color)); - if (loaded) { for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp) XftColorFree(xw.dpy, xw.vis, xw.cmap, cp); + } else { + dc.collen = MAX(LEN(colorname), 256); + dc.col = xmalloc(dc.collen * sizeof(Color)); } for (i = 0; i < dc.collen; i++) From 3061ebd7e17053bb0a928eda868136a4d5f59997 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sun, 4 Nov 2018 14:30:56 +0100 Subject: [PATCH 3/5] st: small typofix in comment --- st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/st.c b/st.c index a6310f7..bc761ba 100644 --- a/st.c +++ b/st.c @@ -2388,7 +2388,7 @@ eschandle(uchar ascii) case 'Z': /* DECID -- Identify Terminal */ ttywrite(vtiden, strlen(vtiden), 0); break; - case 'c': /* RIS -- Reset to inital state */ + case 'c': /* RIS -- Reset to initial state */ treset(); resettitle(); xloadcols(); From e651f316420d4366605cd5614b4b6ede46ea451a Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Tue, 11 Dec 2018 11:43:03 +0200 Subject: [PATCH 4/5] output child WEXITSTATUS/WTERMSIG on abnormal termination --- st.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/st.c b/st.c index bc761ba..5a2a898 100644 --- a/st.c +++ b/st.c @@ -738,8 +738,10 @@ sigchld(int a) if (pid != p) return; - if (!WIFEXITED(stat) || WEXITSTATUS(stat)) - die("child finished with error '%d'\n", stat); + if (WIFEXITED(stat) && WEXITSTATUS(stat)) + die("child exited with status %d\n", WEXITSTATUS(stat)); + else if (WIFSIGNALED(stat)) + die("child terminated due to signal %d\n", WTERMSIG(stat)); exit(0); } From 7a1a92ff3f331047245837ddd055298ceb013a62 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Tue, 11 Sep 2018 19:06:35 +0200 Subject: [PATCH 5/5] small code-style fix --- st.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/st.c b/st.c index 5a2a898..9fd04bd 100644 --- a/st.c +++ b/st.c @@ -1506,7 +1506,8 @@ tsetattr(int *attr, int l) } else { fprintf(stderr, "erresc(default): gfx attr %d unknown\n", - attr[i]), csidump(); + attr[i]); + csidump(); } break; }