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

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