Posted to tcl by mjanssen at Mon Jun 04 19:08:26 GMT 2007view raw

  1. Index: generic/tclCep.c
  2. ===================================================================
  3. --- generic/tclCep.c (revision 240)
  4. +++ generic/tclCep.c (working copy)
  5. @@ -417,7 +417,7 @@
  6. * connection. */
  7. const char *addr ; /* Address of client that was
  8. * accepted. */
  9. - int port;
  10. + int port,i;
  11. int cepDomain;
  12. uid_t euid;
  13. gid_t egid;
  14. @@ -451,6 +451,15 @@
  15. cmd[4] = Tcl_NewIntObj((signed) egid);
  16. cmd[5] = Tcl_NewByteArrayObj(data, (signed) egid);
  17.  
  18. + /*
  19. + * increase refcount so the cmd elements are guaranteed
  20. + * to still exist after calling TEOv
  21. + */
  22. +
  23. + for (i=0 ; i<6 ; i++) {
  24. + Tcl_IncrRefCount(cmd[i]);
  25. + }
  26. +
  27. /*
  28. * Artificially bump the refcount to protect the channel from
  29. * being deleted while the script is being evaluated.
  30. @@ -466,6 +475,15 @@
  31. }
  32.  
  33. /*
  34. + * Decrease refcounts of cmd elements because we wont keep a
  35. + * reference to them
  36. + */
  37. +
  38. + for (i=0 ; i<6 ; i++) {
  39. + Tcl_DecrRefCount(cmd[i]);
  40. + }
  41. +
  42. + /*
  43. * Decrement the artificially bumped refcount. After this it is
  44. * not safe anymore to use "chan", because it may now be deleted.