Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: 4.0.4: segmentation fault from termcap/terminfo



> zsh -f
% echo $terminfo | less

% echo $terminfo | less
Segmentation fault

termcap.c and terminfo.c both try to set both gets.cfn to strgetfn and gets.ifn to intgetfn but gets is a union so they can't be set to different things.  intgetfn seems to work ? for strings on AIX but not on IRIX.

We seem to be able to set the appropriate union member at the time we need it:

--- Src/Modules/terminfo.c.orig Fri Apr 27 03:54:06 2001
+++ Src/Modules/terminfo.c      Thu Jul 25 07:42:18 2002
@@ -175,10 +175,6 @@
     pm = (Param) zhalloc(sizeof(struct param));
     pm->nam = dupstring(name);
     pm->flags = PM_READONLY;
-    pm->sets.cfn = NULL;
-    pm->gets.cfn = strgetfn;
-    pm->sets.ifn = NULL;
-    pm->gets.ifn = intgetfn;
     pm->unsetfn = NULL;
     pm->ct = 0;
     pm->env = NULL;
@@ -189,15 +185,21 @@
     if (((num = tigetnum(name)) != -1) && (num != -2)) {
        pm->u.val = num;
        pm->flags |= PM_INTEGER;
+       pm->sets.ifn = NULL;
+       pm->gets.ifn = intgetfn;
     }
     else if ((num = tigetflag(name)) != -1) {
        pm->u.str = num ? dupstring("yes") : dupstring("no");
        pm->flags |= PM_SCALAR;
+       pm->sets.cfn = NULL;
+       pm->gets.cfn = strgetfn;
     }
     else if ((tistr = (char *)tigetstr(name)) != NULL && tistr != (char *)-1)
     {
        pm->u.str = dupstring(tistr);
        pm->flags |= PM_SCALAR;
+       pm->sets.cfn = NULL;
+       pm->gets.cfn = strgetfn;
     }
     else
     {
@@ -287,10 +289,6 @@
 #endif
 
     pm = (Param) zhalloc(sizeof(struct param));
-    pm->sets.cfn = NULL;
-    pm->gets.cfn = strgetfn;
-    pm->sets.ifn = NULL;
-    pm->gets.ifn = intgetfn;
     pm->unsetfn = NULL;
     pm->ct = 0;
     pm->env = NULL;
@@ -298,6 +296,9 @@
     pm->old = NULL;
     
     pm->flags = PM_READONLY | PM_SCALAR;
+    pm->sets.cfn = NULL;
+    pm->gets.cfn = strgetfn;
+
     for (capname = (char **)boolnames; *capname; capname++) {
        if ((num = tigetflag(*capname)) != -1) {
            pm->u.str = num ? dupstring("yes") : dupstring("no");
@@ -305,8 +306,11 @@
            func((HashNode) pm, flags);
        }
     }
-    
+
     pm->flags = PM_READONLY | PM_INTEGER;
+    pm->sets.ifn = NULL;
+    pm->gets.ifn = intgetfn;
+
     for (capname = (char **)numnames; *capname; capname++) {
        if (((num = tigetnum(*capname)) != -1) && (num != -2)) {
            pm->u.val = num;
@@ -314,8 +318,11 @@
            func((HashNode) pm, flags);
        }
     }
-    
+
     pm->flags = PM_READONLY | PM_SCALAR;
+    pm->sets.cfn = NULL;
+    pm->gets.cfn = strgetfn;
+
     for (capname = (char **)strnames; *capname; capname++) {
        if ((tistr = (char *)tigetstr(*capname)) != NULL &&
            tistr != (char *)-1) {
--- Src/Modules/termcap.c.orig  Thu Jul 25 07:40:01 2002
+++ Src/Modules/termcap.c       Thu Jul 25 07:47:19 2002
@@ -236,10 +236,6 @@
     pm = (Param) zhalloc(sizeof(struct param));
     pm->nam = dupstring(name);
     pm->flags = PM_READONLY;
-    pm->sets.cfn = NULL;
-    pm->gets.cfn = strgetfn;
-    pm->sets.ifn = NULL;
-    pm->gets.ifn = intgetfn;
     pm->unsetfn = NULL;
     pm->ct = 0;
     pm->env = NULL;
@@ -251,10 +247,15 @@
     /* logic in the following cascade copied from echotc, above */
 
     if ((num = tgetnum(name)) != -1) {
+      pm->sets.ifn = NULL;
+      pm->gets.ifn = intgetfn;
        pm->u.val = num;
        pm->flags |= PM_INTEGER;
        return (HashNode) pm;
     }
+
+    pm->sets.cfn = NULL;
+    pm->gets.cfn = strgetfn;
     switch (ztgetflag(name)) {
     case -1:
        break;
@@ -338,10 +339,6 @@
 #endif
 
     pm = (Param) zhalloc(sizeof(struct param));
-    pm->sets.cfn = NULL;
-    pm->gets.cfn = strgetfn;
-    pm->sets.ifn = NULL;
-    pm->gets.ifn = intgetfn;
     pm->unsetfn = NULL;
     pm->ct = 0;
     pm->env = NULL;
@@ -350,6 +347,9 @@
     u = buf;
 
     pm->flags = PM_READONLY | PM_SCALAR;
+    pm->sets.cfn = NULL;
+    pm->gets.cfn = strgetfn;
+
     for (capcode = (char **)boolcodes; *capcode; capcode++) {
        if ((num = ztgetflag(*capcode)) != -1) {
            pm->u.str = num ? dupstring("yes") : dupstring("no");
@@ -359,6 +359,9 @@
     }
 
     pm->flags = PM_READONLY | PM_INTEGER;
+    pm->sets.ifn = NULL;
+    pm->gets.ifn = intgetfn;
+
     for (capcode = (char **)numcodes; *capcode; capcode++) {
        if ((num = tgetnum(*capcode)) != -1) {
            pm->u.val = num;
@@ -368,6 +371,9 @@
     }
 
     pm->flags = PM_READONLY | PM_SCALAR;
+    pm->sets.cfn = NULL;
+    pm->gets.cfn = strgetfn;
+
     for (capcode = (char **)strcodes; *capcode; capcode++) {
        if ((tcstr = (char *)tgetstr(*capcode,&u)) != NULL &&
            tcstr != (char *)-1) {



Messages sorted by: Reverse Date, Date, Thread, Author