diff options
author | dgp <dgp@users.sourceforge.net> | 2002-02-28 00:53:32 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2002-02-28 00:53:32 (GMT) |
commit | dfa5329058b763cbe42687ceba9095b5b13c5c2a (patch) | |
tree | 73f3e2e794f7287ca5173f2582836a8419ec9e3b /generic/tclMain.c | |
parent | 7b4c011ac00349355a6805ea3f30f8f02f5e9169 (diff) | |
download | tcl-dfa5329058b763cbe42687ceba9095b5b13c5c2a.zip tcl-dfa5329058b763cbe42687ceba9095b5b13c5c2a.tar.gz tcl-dfa5329058b763cbe42687ceba9095b5b13c5c2a.tar.bz2 |
* generic/tclMain.c (Tcl_Main,StdinProc): Corrected some reference
count management errors on the interactive commandPtr Tcl_Obj found by
Purify. Thanks to Jeff Hobbs for the report and assistance.
Diffstat (limited to 'generic/tclMain.c')
-rw-r--r-- | generic/tclMain.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/generic/tclMain.c b/generic/tclMain.c index 53dc064..4bc67b6 100644 --- a/generic/tclMain.c +++ b/generic/tclMain.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclMain.c,v 1.17 2002/01/25 20:40:55 dgp Exp $ + * RCS: @(#) $Id: tclMain.c,v 1.18 2002/02/28 00:53:32 dgp Exp $ */ #include "tcl.h" @@ -353,6 +353,11 @@ Tcl_Main(argc, argv, appInitProc) break; } } + if (Tcl_IsShared(commandPtr)) { + Tcl_DecrRefCount(commandPtr); + commandPtr = Tcl_DuplicateObj(commandPtr); + Tcl_IncrRefCount(commandPtr); + } length = Tcl_GetsObj(inChannel, commandPtr); if (length < 0) { if (Tcl_InputBlocked(inChannel)) { @@ -380,6 +385,11 @@ Tcl_Main(argc, argv, appInitProc) * Add the newline removed by Tcl_GetsObj back to the string. */ + if (Tcl_IsShared(commandPtr)) { + Tcl_DecrRefCount(commandPtr); + commandPtr = Tcl_DuplicateObj(commandPtr); + Tcl_IncrRefCount(commandPtr); + } Tcl_AppendToObj(commandPtr, "\n", 1); if (!TclObjCommandComplete(commandPtr)) { prompt = PROMPT_CONTINUE; @@ -401,11 +411,13 @@ Tcl_Main(argc, argv, appInitProc) } } else if (tty) { resultPtr = Tcl_GetObjResult(interp); + Tcl_IncrRefCount(resultPtr); Tcl_GetStringFromObj(resultPtr, &length); if ((length > 0) && outChannel) { Tcl_WriteObj(outChannel, resultPtr); Tcl_WriteChars(outChannel, "\n", 1); } + Tcl_DecrRefCount(resultPtr); } if (mainLoopProc != NULL) { @@ -446,6 +458,7 @@ Tcl_Main(argc, argv, appInitProc) Tcl_LinkVar(interp, "tcl_interactive", (char *) &tty, TCL_LINK_BOOLEAN); prompt = isPtr->prompt; + commandPtr = isPtr->commandPtr; if (isPtr->input != (Tcl_Channel) NULL) { Tcl_DeleteChannelHandler(isPtr->input, StdinProc, (ClientData) isPtr); @@ -573,6 +586,11 @@ StdinProc(clientData, mask) Tcl_Interp *interp = isPtr->interp; int code, length; + if (Tcl_IsShared(commandPtr)) { + Tcl_DecrRefCount(commandPtr); + commandPtr = Tcl_DuplicateObj(commandPtr); + Tcl_IncrRefCount(commandPtr); + } length = Tcl_GetsObj(chan, commandPtr); if (length < 0) { if (Tcl_InputBlocked(chan)) { @@ -590,6 +608,11 @@ StdinProc(clientData, mask) return; } + if (Tcl_IsShared(commandPtr)) { + Tcl_DecrRefCount(commandPtr); + commandPtr = Tcl_DuplicateObj(commandPtr); + Tcl_IncrRefCount(commandPtr); + } Tcl_AppendToObj(commandPtr, "\n", 1); if (!TclObjCommandComplete(commandPtr)) { isPtr->prompt = PROMPT_CONTINUE; @@ -624,11 +647,13 @@ StdinProc(clientData, mask) } else if (isPtr->tty) { Tcl_Obj *resultPtr = Tcl_GetObjResult(interp); Tcl_Channel outChannel = Tcl_GetStdChannel(TCL_STDOUT); + Tcl_IncrRefCount(resultPtr); Tcl_GetStringFromObj(resultPtr, &length); if ((length >0) && (outChannel != (Tcl_Channel) NULL)) { Tcl_WriteObj(outChannel, resultPtr); Tcl_WriteChars(outChannel, "\n", 1); } + Tcl_DecrRefCount(resultPtr); } /* |