From: ian Date: Sun, 19 Dec 2004 20:34:52 +0000 (+0000) Subject: scriptinv is correct about not leaking xargs. do not pointlessly trash the args... X-Git-Tag: debian/1.1.1~107 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-tcl.git;a=commitdiff_plain;h=2bdb81ea2a5035b0b3a37ec819ee12edb8595f76 scriptinv is correct about not leaking xargs. do not pointlessly trash the args to scriptinv_invoke --- diff --git a/base/chiark-tcl.h b/base/chiark-tcl.h index 875b239..1bf433b 100644 --- a/base/chiark-tcl.h +++ b/base/chiark-tcl.h @@ -212,7 +212,7 @@ int scriptinv_set(ScriptToInvoke *si, Tcl_Interp *ip, void scriptinv_cancel(ScriptToInvoke *si); /* then don't invoke */ /* no separate free function - just cancel */ -void scriptinv_invoke(ScriptToInvoke *si, int argc, Tcl_Obj **argv); +void scriptinv_invoke(ScriptToInvoke *si, int argc, Tcl_Obj *const *argv); /* from idtable.c */ diff --git a/base/scriptinv.c b/base/scriptinv.c index cdaec8b..482f487 100644 --- a/base/scriptinv.c +++ b/base/scriptinv.c @@ -5,13 +5,12 @@ void scriptinv_init(ScriptToInvoke *si) { si->obj= 0; + si->xargs= 0; } void scriptinv_cancel(ScriptToInvoke *si) { - if (si->obj) { - Tcl_DecrRefCount(si->obj); - si->obj= 0; - } + if (si->obj) { Tcl_DecrRefCount(si->obj); si->obj= 0; } + if (si->xargs) { Tcl_DecrRefCount(si->xargs); si->xargs= 0; } } int scriptinv_set(ScriptToInvoke *si, Tcl_Interp *ip, @@ -35,12 +34,11 @@ int scriptinv_set(ScriptToInvoke *si, Tcl_Interp *ip, return 0; } -void scriptinv_invoke(ScriptToInvoke *si, int argc, Tcl_Obj **argv) { +void scriptinv_invoke(ScriptToInvoke *si, int argc, Tcl_Obj *const *argv) { Tcl_Obj *invoke=0; int i, rc; assert(si->obj); - for (i=0; iobj); @@ -52,7 +50,6 @@ void scriptinv_invoke(ScriptToInvoke *si, int argc, Tcl_Obj **argv) { } rc= Tcl_ListObjReplace(si->ip, invoke,si->llength,0, argc,argv); - for (i=0; iip,invoke,TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT); @@ -61,6 +58,7 @@ void scriptinv_invoke(ScriptToInvoke *si, int argc, Tcl_Obj **argv) { rc= 0; x_rc: + for (i=0; iip); } diff --git a/hbytes/hbytes.h b/hbytes/hbytes.h index 875b239..1bf433b 100644 --- a/hbytes/hbytes.h +++ b/hbytes/hbytes.h @@ -212,7 +212,7 @@ int scriptinv_set(ScriptToInvoke *si, Tcl_Interp *ip, void scriptinv_cancel(ScriptToInvoke *si); /* then don't invoke */ /* no separate free function - just cancel */ -void scriptinv_invoke(ScriptToInvoke *si, int argc, Tcl_Obj **argv); +void scriptinv_invoke(ScriptToInvoke *si, int argc, Tcl_Obj *const *argv); /* from idtable.c */