From cee011a388e7c94a2b7a786d87d1cd200fcf5fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Dole=C5=BEal?= Date: Wed, 7 Nov 2018 16:10:31 +0100 Subject: [PATCH] Fix for nomem handling in resize.c:ChangeWindowSize() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move `nomem' label of ChangeWindowSize() to the end of function and add test for value of `nhlines' Signed-off-by: Vaclav Dolezal Signed-off-by: Amadeusz Sławiński w_tabs ? p->w_width : 0; p->w_tabs = xrealloc(p->w_tabs, (wi + 1) * 4); - if (p->w_tabs == NULL) { - nomem: - if (nmlines) { - for (ty = he + hi - 1; ty >= 0; ty--) { - mlt = NEWWIN(ty); - FreeMline(mlt); - } - if (nmlines && p->w_mlines != nmlines) - free((char *)nmlines); - if (nhlines && p->w_hlines != nhlines) - free((char *)nhlines); - } - KillWindow(p); - Msg(0, "%s", strnomem); - return -1; - } + if (p->w_tabs == NULL) + goto nomem; for (; t < wi; t++) p->w_tabs[t] = t && !(t & 7) ? 1 : 0; p->w_tabs[wi] = 0; @@ -747,6 +733,21 @@ int ChangeWindowSize(Window *p, int wi, int he, int hi) #endif return 0; + +nomem: + if (nmlines) { + for (ty = he + hi - 1; ty >= 0; ty--) { + mlt = NEWWIN(ty); + FreeMline(mlt); + } + if (nmlines && p->w_mlines != nmlines) + free((char *)nmlines); + if (nhlines && p->w_hlines != nhlines) + free((char *)nhlines); + } + KillWindow(p); + Msg(0, "%s", strnomem); + return -1; } void FreeAltScreen(Window *p)