Posted to tcl by mjanssen at Mon Jun 04 19:07:21 GMT 2007view pretty

> svn diff
Index: generic/tclCep.c
===================================================================
--- generic/tclCep.c    (revision 240)
+++ generic/tclCep.c    (working copy)
@@ -417,7 +417,7 @@
                                          * connection. */
     const char *addr ;                 /* Address of client that was
                                          * accepted. */
-    int port;
+    int port,i;
     int cepDomain;
     uid_t euid;
     gid_t egid;
@@ -451,6 +451,15 @@
        cmd[4] = Tcl_NewIntObj((signed) egid);
        cmd[5] = Tcl_NewByteArrayObj(data, (signed) egid);

+    /*
+     * increase refcount so the cmd elements are guaranteed
+     * to still exist after calling TEOv
+    */
+
+    for (i=0 ; i<=6 ; i++) {
+        Tcl_IncrRefCount(cmd[i]);
+    }
+
         /*
          * Artificially bump the refcount to protect the channel from
          * being deleted while the script is being evaluated.
@@ -466,6 +475,15 @@
         }

         /*
+         * Decrease refcounts of cmd elements because we wont keep a
+         * reference to them
+         */
+
+        for (i=0 ; i<=6 ; i++) {
+            Tcl_DecrRefCount(cmd[i]);
+        }
+
+        /*
          * Decrement the artificially bumped refcount. After this it is
          * not safe anymore to use "chan", because it may now be deleted.
          */