screen-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[screen-devel] [PATCH 4/6] Fix for nomem handling in resize.c:ChangeWind


From: Václav Doležal
Subject: [screen-devel] [PATCH 4/6] Fix for nomem handling in resize.c:ChangeWindowSize()
Date: Wed, 7 Nov 2018 16:10:31 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1

Move `nomem' label of ChangeWindowSize() to the end of function and
add test for value of `nhlines'

Signed-off-by: Vaclav Dolezal <address@hidden>
---
 src/resize.c | 40 ++++++++++++++++++++--------------------
 1 file 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
-- 
2.14.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]