Index: ChangeLog ================================================================== --- ChangeLog +++ ChangeLog @@ -1,8 +1,9 @@ 2008-03-19 Jeff Hobbs * tls.c (Tls_Clean, ImportObjCmd): Fix cleanup mem leak [Bug 1414045] + Use better Eval APIs, cleaner Tcl_Obj-handling. 2008-03-19 Pat Thoyts * win/Makefile.vc Updated the nmake build files with MSVC9 support * win/rules.vc: and fixed to run the test-suite properly. Index: tls.c ================================================================== --- tls.c +++ tls.c @@ -3,11 +3,11 @@ * some modifications: * Copyright (C) 2000 Ajuba Solutions * Copyright (C) 2002 ActiveState Corporation * Copyright (C) 2004 Starfish Systems * - * $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.c,v 1.28 2008/03/19 19:59:40 hobbs2 Exp $ + * $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.c,v 1.29 2008/03/19 21:31:24 hobbs2 Exp $ * * TLS (aka SSL) Channel - can be layered on any bi-directional * Tcl_Channel (Note: Requires Trf Core Patch) * * This was built (almost) from scratch based upon observation of @@ -208,11 +208,11 @@ } Tcl_Preserve( (ClientData) statePtr->interp); Tcl_Preserve( (ClientData) statePtr); Tcl_IncrRefCount( cmdPtr); - (void) Tcl_GlobalEvalObj(statePtr->interp, cmdPtr); + (void) Tcl_EvalObjEx(statePtr->interp, cmdPtr, TCL_EVAL_GLOBAL); Tcl_DecrRefCount( cmdPtr); Tcl_Release( (ClientData) statePtr); Tcl_Release( (ClientData) statePtr->interp); @@ -289,11 +289,11 @@ Tcl_Preserve( (ClientData) statePtr); statePtr->flags |= TLS_TCL_CALLBACK; Tcl_IncrRefCount( cmdPtr); - if (Tcl_GlobalEvalObj(statePtr->interp, cmdPtr) != TCL_OK) { + if (Tcl_EvalObjEx(statePtr->interp, cmdPtr, TCL_EVAL_GLOBAL) != TCL_OK) { /* It got an error - reject the certificate. */ Tcl_BackgroundError( statePtr->interp); ok = 0; } else { result = Tcl_GetObjResult(statePtr->interp); @@ -362,11 +362,11 @@ Tcl_Preserve((ClientData) statePtr->interp); Tcl_Preserve((ClientData) statePtr); Tcl_IncrRefCount(cmdPtr); - if (Tcl_GlobalEvalObj(statePtr->interp, cmdPtr) != TCL_OK) { + if (Tcl_EvalObjEx(statePtr->interp, cmdPtr, TCL_EVAL_GLOBAL) != TCL_OK) { Tcl_BackgroundError(statePtr->interp); } Tcl_DecrRefCount(cmdPtr); Tcl_Release((ClientData) statePtr); @@ -401,11 +401,12 @@ Tcl_Interp *interp = statePtr->interp; Tcl_Obj *cmdPtr; int result; if (statePtr->password == NULL) { - if (Tcl_Eval(interp, "tls::password") == TCL_OK) { + if (Tcl_EvalEx(interp, "tls::password", -1, TCL_EVAL_GLOBAL) + == TCL_OK) { char *ret = (char *) Tcl_GetStringResult(interp); strncpy(buf, ret, (size_t) size); return (int)strlen(ret); } else { return -1; @@ -416,11 +417,11 @@ Tcl_Preserve((ClientData) statePtr->interp); Tcl_Preserve((ClientData) statePtr); Tcl_IncrRefCount(cmdPtr); - result = Tcl_GlobalEvalObj(interp, cmdPtr); + result = Tcl_EvalObjEx(interp, cmdPtr, TCL_EVAL_GLOBAL); if (result != TCL_OK) { Tcl_BackgroundError(statePtr->interp); } Tcl_DecrRefCount(cmdPtr); @@ -658,11 +659,11 @@ Tcl_Channel chan; /* The channel to set a mode on. */ State *statePtr; /* client state for ssl socket */ SSL_CTX *ctx = NULL; Tcl_Obj *script = NULL; Tcl_Obj *password = NULL; - int idx; + int idx, len; int flags = TLS_TCL_INIT; int server = 0; /* is connection incoming or outgoing? */ char *key = NULL; char *cert = NULL; char *ciphers = NULL; @@ -753,22 +754,22 @@ statePtr->vflags = verify; statePtr->err = ""; /* allocate script */ if (script) { - char *tmp = Tcl_GetStringFromObj(script, NULL); - if (tmp && *tmp) { - statePtr->callback = Tcl_DuplicateObj(script); + (void) Tcl_GetStringFromObj(script, &len); + if (len) { + statePtr->callback = script; Tcl_IncrRefCount(statePtr->callback); } } /* allocate password */ if (password) { - char *tmp = Tcl_GetStringFromObj(password, NULL); - if (tmp && *tmp) { - statePtr->password = Tcl_DuplicateObj(password); + (void) Tcl_GetStringFromObj(password, &len); + if (len) { + statePtr->password = password; Tcl_IncrRefCount(statePtr->password); } } if (model != NULL) { @@ -792,11 +793,11 @@ return TCL_ERROR; } ctx = ((State *)Tcl_GetChannelInstanceData(chan))->ctx; } else { if ((ctx = CTX_Init(statePtr, proto, key, cert, CAdir, CAfile, ciphers)) - == (SSL_CTX*)0) { + == (SSL_CTX*)0) { Tls_Free((char *) statePtr); return TCL_ERROR; } }