diff options
author | dgp <dgp@noemail.net> | 2002-02-28 00:53:31 (GMT) |
---|---|---|
committer | dgp <dgp@noemail.net> | 2002-02-28 00:53:31 (GMT) |
commit | de0e8e65020001b3fe87406d0cfa147c545e7b27 (patch) | |
tree | 73f3e2e794f7287ca5173f2582836a8419ec9e3b /generic/tclMain.c | |
parent | fc7dd40a0b36d42f15de78052db02a18f9c0c38d (diff) | |
download | tcl-de0e8e65020001b3fe87406d0cfa147c545e7b27.zip tcl-de0e8e65020001b3fe87406d0cfa147c545e7b27.tar.gz tcl-de0e8e65020001b3fe87406d0cfa147c545e7b27.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.
FossilOrigin-Name: a3947b277a9901f1ac20e4f0ac16d4903070b567
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); } /* |