summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVáclav Doležal <vdolezal@redhat.com>2018-11-07 16:10:31 +0100
committerAmadeusz Sławiński <amade@asmblr.net>2018-11-18 16:22:03 +0100
commitcee011a388e7c94a2b7a786d87d1cd200fcf5fa7 (patch)
treef7af6b3002f80de84b11e55756729fb44fd9949d
parenta47b9801fb6867af115b13b09a5c9b83718aa186 (diff)
downloadscreen-cee011a388e7c94a2b7a786d87d1cd200fcf5fa7.tar.gz
Fix for nomem handling in resize.c:ChangeWindowSize()
Move `nomem' label of ChangeWindowSize() to the end of function and add test for value of `nhlines' Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com> Signed-off-by: Amadeusz Sławiński <amade@asmblr.net
-rw-r--r--src/resize.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/resize.c b/src/resize.c
index 13d7ee6..ee9ac82 100644
--- a/src/resize.c
+++ b/src/resize.c
@@ -669,22 +669,8 @@ int ChangeWindowSize(Window *p, int wi, int he, int hi)
if (wi) {
t = p->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)