You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tcl.apache.org by mx...@apache.org on 2019/05/24 11:05:00 UTC

[tcl-rivet] branch master updated: Add Tcl_DecrRefCnt after RivetCache_StoreScript as this function itself calls Tcl_IncrRefCnt to preserve the Tcl_Obj with the script code

This is an automated email from the ASF dual-hosted git repository.

mxmanghi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git


The following commit(s) were added to refs/heads/master by this push:
     new ac0b9cb  Add Tcl_DecrRefCnt after RivetCache_StoreScript as this function itself calls Tcl_IncrRefCnt to preserve the Tcl_Obj with the script code
ac0b9cb is described below

commit ac0b9cbae71ceb2e62f12ad7f66a492c4de884ef
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Fri May 24 12:48:02 2019 +0200

    Add Tcl_DecrRefCnt after RivetCache_StoreScript as this function itself calls Tcl_IncrRefCnt to preserve the Tcl_Obj with the script code
    
    (cherry picked from commit 26d1c85ae55ea31641c3bacb2f96debd4622bed7)
---
 ChangeLog                          | 5 +++++
 src/mod_rivet_ng/mod_rivet_cache.c | 6 +++---
 src/mod_rivet_ng/rivetCore.c       | 2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 43dd983..d1c8088 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-05-24 Massimo Manghi <mx...@apache.org>
+    * src/mod_rivet_ng/rivetCore.c: Add Tcl_DecrRefCnt after
+    RivetCache_StoreScript as this function itself calls
+    Tcl_IncrRefCnt to preserve the Tcl_Obj with the script code
+    
 2019-04-13 Massimo Manghi <mx...@apache.org>
     * doc/xml/commands.xml: Correct wrong header in ::rivet::http_accept code example
 
diff --git a/src/mod_rivet_ng/mod_rivet_cache.c b/src/mod_rivet_ng/mod_rivet_cache.c
index 9371a36..721c8d9 100644
--- a/src/mod_rivet_ng/mod_rivet_cache.c
+++ b/src/mod_rivet_ng/mod_rivet_cache.c
@@ -198,9 +198,9 @@ int RivetCache_StoreScript(rivet_thread_interp* rivet_interp, Tcl_HashEntry* ent
         if (rivet_interp->cache_free) {
             char* hashKey = (char *) Tcl_GetHashKey (rivet_interp->objCache,entry);
 
-            /* We need to incr the reference count of outbuf because we want
-             * it to outlive this function.  This allows it to stay alive
-             * as long as it's in the object cache.
+            /* Tcl_SetHashValue is a macro that simply stuffs the value pointer in an array
+             * We need to incr the reference count of outbuf because we want it to outlive 
+             * this function and be kept as long as the cache is preserved
              */
 
             Tcl_IncrRefCount (script);
diff --git a/src/mod_rivet_ng/rivetCore.c b/src/mod_rivet_ng/rivetCore.c
index 94c066d..38aef69 100644
--- a/src/mod_rivet_ng/rivetCore.c
+++ b/src/mod_rivet_ng/rivetCore.c
@@ -307,12 +307,12 @@ TCL_CMD_HEADER( Rivet_Parse )
         }
         
         RivetCache_StoreScript(rivet_interp,entry,script);
+        Tcl_DecrRefCount(script);
     } else {
         script = RivetCache_FetchScript(entry);
     }
 
     return Tcl_EvalObjEx(interp,script,0); 
-    //return Rivet_ParseExecFile(private,filename,0);
 }
 
 /*


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tcl.apache.org
For additional commands, e-mail: commits-help@tcl.apache.org