]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
- don't blow the stack if we push a help line that is longer than the r0-50-21
authormsw <msw>
Fri, 30 Mar 2001 21:45:58 +0000 (21:45 +0000)
committermsw <msw>
Fri, 30 Mar 2001 21:45:58 +0000 (21:45 +0000)
  curret number of columns
- clip window to screen bounds so that if we get a window that is
  larger than the screen we can still redraw the windows behind it
  when we pop

configure.in
newt.c
newt.spec

index ea2923b0f5955f7e7695dab448455719e41adbc5..1ddaa4a85b05d36636c3a31c454675ec1c0e0f3c 100644 (file)
@@ -5,7 +5,7 @@ AC_CONFIG_HEADER(config.h)
 
 VERSION=$(awk '/^%define version/ {print $3}' newt.spec)
 
-VERSION=0.50.20
+VERSION=0.50.21
 SONAME=0.50
 AC_SUBST(VERSION)
 AC_SUBST(SONAME)
diff --git a/newt.c b/newt.c
index f919c33a335f536cb93a747f17405ee2fecd3602..42b0371a457812fb2198c217098d96f80989f7d6 100644 (file)
--- a/newt.c
+++ b/newt.c
@@ -394,11 +394,20 @@ int newtOpenWindow(int left, int top, int width, int height,
 
     row = top - 1;
     col = left - 1;
+    /* clip to the current screen bounds - msw */
+    if (row < 0)
+       row = 0;
+    if (col < 0)
+       col = 0;
+    if (left + width > SLtt_Screen_Cols)
+       width = SLtt_Screen_Cols - left;
+    if (top + height > SLtt_Screen_Rows)
+       height = SLtt_Screen_Rows - top;
     n = 0;
     for (j = 0; j < height + 3; j++, row++) {
        SLsmg_gotorc(row, col);
        SLsmg_read_raw(currentWindow->buffer + n,
-                               currentWindow->width + 3);
+                      currentWindow->width + 3);
        n += currentWindow->width + 3;
     }
 
@@ -460,10 +469,14 @@ void newtPopWindow(void) {
 
     row = currentWindow->top - 1;
     col = currentWindow->left - 1;
+    if (row < 0)
+       row = 0;
+    if (col < 0)
+       col = 0;
     for (j = 0; j < currentWindow->height + 3; j++, row++) {
        SLsmg_gotorc(row, col);
        SLsmg_write_raw(currentWindow->buffer + n,
-                               currentWindow->width + 3);
+                       currentWindow->width + 3);
        n += currentWindow->width + 3;
     }
 
@@ -578,9 +591,12 @@ void newtRedrawHelpLine(void) {
     memset(buf, ' ', SLtt_Screen_Cols);
     buf[SLtt_Screen_Cols] = '\0';
 
-    if (currentHelpline)
-       memcpy(buf, *currentHelpline, strlen(*currentHelpline));
-
+    if (currentHelpline) {
+       int len = strlen(*currentHelpline);
+       if (SLtt_Screen_Cols < len)
+           len = SLtt_Screen_Cols;
+       memcpy(buf, *currentHelpline, len);
+    }
     SLsmg_gotorc(SLtt_Screen_Rows - 1, 0);
     SLsmg_write_string(buf);
 }
index ddcd1f826303a99b4590cbd1fdab3371e6bdf7c2..3be4f457a80cfb86547f89fa35a079eaefbdfd34 100644 (file)
--- a/newt.spec
+++ b/newt.spec
@@ -1,8 +1,8 @@
 Summary: A development library for text mode user interfaces.
 Name: newt
-%define version 0.50.20
+%define version 0.50.21
 Version: %{version}
-Release: 4
+Release: 1
 Copyright: LGPL
 Group: System Environment/Libraries
 Source: ftp://ftp.redhat.com/pub/redhat/code/newt/newt-%{version}.tar.gz
@@ -105,6 +105,13 @@ rm -rf $RPM_BUILD_ROOT
 %endif
 
 %changelog
+* Fri Mar 30 2001 Matt Wilson <msw@redhat.com>
+- don't blow the stack if we push a help line that is longer than the
+  curret number of columns
+- clip window to screen bounds so that if we get a window that is
+  larger than the screen we can still redraw the windows behind it
+  when we pop
+
 * Sun Feb 11 2001 Than Ngo <than@redhat.com>
 - disable building new-python2 sub package again