]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
- free helplines and windows in newtFinished, check for overflow (#239992)
authormlichvar <mlichvar>
Tue, 15 May 2007 10:38:09 +0000 (10:38 +0000)
committermlichvar <mlichvar>
Tue, 15 May 2007 10:38:09 +0000 (10:38 +0000)
newt.c
newt.spec

diff --git a/newt.c b/newt.c
index 8b20dab097260435954745b72ff65dce38bf6e8a..d4bd778753d8561040317adc3daa3721a03de8ae 100644 (file)
--- a/newt.c
+++ b/newt.c
@@ -321,6 +321,20 @@ int newtInit(void) {
  * @returns int , 0. (no errors reported)
  */
 int newtFinished(void) {
+    if (currentWindow) {
+       for (; currentWindow >= windowStack; currentWindow--) {
+           free(currentWindow->buffer);
+           free(currentWindow->title);
+       }
+       currentWindow = NULL;
+    }
+
+    if (currentHelpline) {
+       for (; currentHelpline >= helplineStack; currentHelpline--)
+           free(*currentHelpline);
+       currentHelpline = NULL;
+    }
+
     SLsmg_gotorc(SLtt_Screen_Rows - 1, 0);
     newtCursorOn();
     SLsmg_refresh();
@@ -622,7 +636,7 @@ void newtClearKeyBuffer(void) {
  * @param width unsigned int
  * @param height unsigned int
  * @param title - title string
- * @return zero on success (currently no errors reported)
+ * @return zero on success
  */
 int newtOpenWindow(int left, int top, 
                    unsigned int width, unsigned int height,
@@ -633,6 +647,10 @@ int newtOpenWindow(int left, int top,
 
     newtFlushInput();
 
+    if (currentWindow && currentWindow - windowStack + 1
+           >= sizeof (windowStack) / sizeof (struct Window))
+       return 1;
+
     if (!currentWindow) {
        currentWindow = windowStack;
     } else {
@@ -711,7 +729,7 @@ int newtOpenWindow(int left, int top,
  * @param width - width in char cells
  * @param height - no. of char cells.
  * @param title - fixed title
- * @returns 0. No errors reported
+ * @returns zero on success
  */
 int newtCenteredWindow(unsigned int width,unsigned int height, 
                        const char * title) {
@@ -724,9 +742,7 @@ int newtCenteredWindow(unsigned int width,unsigned int height,
 
     left = (int)(SLtt_Screen_Cols - width) / 2;
 
-    newtOpenWindow(left, top, width, height, title);
-
-    return 0;
+    return newtOpenWindow(left, top, width, height, title);
 }
 
 /**
@@ -741,6 +757,9 @@ void newtPopWindowNoRefresh(void) {
     int j, row, col;
     int n = 0;
 
+    if (currentWindow == NULL)
+       return;
+
     row = col = 0;
 
     row = currentWindow->top - 1;
@@ -907,6 +926,10 @@ void newtRedrawHelpLine(void) {
 }
 
 void newtPushHelpLine(const char * text) {
+    if (currentHelpline && currentHelpline - helplineStack + 1
+           >= sizeof (helplineStack) / sizeof (char *))
+       return;
+
     if (!text)
        text = defaultHelpLine;
 
index af7a7928d29bb36628d58f768806a4ba05a9dacc..ca10eec04c6b018245c46a4344a42fb5ed3a1410 100644 (file)
--- a/newt.spec
+++ b/newt.spec
@@ -88,6 +88,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/libnewt.a
 
 %changelog
+- free helplines and windows in newtFinished, check for overflow (#239992)
 - add release to -devel and -static requires (#238784)
 - fix cursor positioning when setting entry or checkbox flags
 - fix counting of items in checkboxtree