mirror of
https://git.savannah.gnu.org/git/screen.git
synced 2026-02-18 21:32:17 +02:00
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
This commit is contained in:
committed by
Amadeusz Sławiński
parent
a47b9801fb
commit
cee011a388
33
src/resize.c
33
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)
|
||||
|
||||
Reference in New Issue
Block a user