diff options
author | Václav Doležal <vdolezal@redhat.com> | 2018-11-07 16:10:31 +0100 |
---|---|---|
committer | Amadeusz Sławiński <amade@asmblr.net> | 2018-11-18 16:00:56 +0100 |
commit | 61d6955517173040b0bc096a9284493e0ad31a1b (patch) | |
tree | 47d1023fcdf16797272e593db182e28b4f26e167 | |
parent | 10ddd81e20a29a8f543a0422bd49d68ccf772a57 (diff) | |
download | screen-61d6955517173040b0bc096a9284493e0ad31a1b.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.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/resize.c b/src/resize.c index 7ed1c93..33e9b81 100644 --- a/src/resize.c +++ b/src/resize.c @@ -938,26 +938,7 @@ int wi, he, hi; t = p->w_tabs ? p->w_width : 0; p->w_tabs = xrealloc(p->w_tabs, wi + 1); if (p->w_tabs == 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); -#ifdef COPY_PASTE - if (nhlines && p->w_hlines != nhlines) - free((char *)nhlines); -#endif - } - KillWindow(p); - Msg(0, "%s", strnomem); - return -1; - } + goto nomem; for (; t < wi; t++) p->w_tabs[t] = t && !(t & 7) ? 1 : 0; p->w_tabs[wi] = 0; @@ -1047,6 +1028,25 @@ int wi, he, hi; } #endif return 0; + +nomem: + if (nmlines || nhlines) + { + for (ty = he + hi - 1; ty >= 0; ty--) + { + mlt = NEWWIN(ty); + FreeMline(mlt); + } + if (nmlines && p->w_mlines != nmlines) + free((char *)nmlines); +#ifdef COPY_PASTE + if (nhlines && p->w_hlines != nhlines) + free((char *)nhlines); +#endif + } + KillWindow(p); + Msg(0, "%s", strnomem); + return -1; } void |