diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2005-10-23 22:01:27 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2005-10-23 22:01:27 (GMT) |
commit | 337481bde00a01912f25ffeda6d5bd4351057c7d (patch) | |
tree | c2da79f4e5a542014dab31edea47e6bd46a22b4c /generic/tclCmdMZ.c | |
parent | 352f9db6131a948693af4acd7d5ae471c54635c2 (diff) | |
download | tcl-337481bde00a01912f25ffeda6d5bd4351057c7d.zip tcl-337481bde00a01912f25ffeda6d5bd4351057c7d.tar.gz tcl-337481bde00a01912f25ffeda6d5bd4351057c7d.tar.bz2 |
* generic/tclBasic.c:
* generic/tclBinary.c:
* generic/tclCmdAH.c:
* generic/tclCmdIL.c:
* generic/tclCmdMZ.c:
* generic/tclExecute.c:
* generic/tclLink.c:
* generic/tclMain.c:
* generic/tclProc.c:
* generic/tclScan.c:
* generic/tclTest.c:
* generic/tclVar.c:
* mac/tclMacInit.c:
* unix/tclUnixInit.c:
* win/tclWinInit.c: Insure that the core never calls TclPtrSetVar,
Tcl_SetVar2Ex, Tcl_ObjSetVar2 or Tcl_SetObjErrorCode with a 0-ref
new value. It is not possible to handle error returns correctly in
that case [Bug 1334947], one has the choice of leaking the object
in some cases, or else risk crashing in some others.
Diffstat (limited to 'generic/tclCmdMZ.c')
-rw-r--r-- | generic/tclCmdMZ.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 1ab108f..d1cb609 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdMZ.c,v 1.82.2.20 2005/06/21 17:19:42 dgp Exp $ + * RCS: @(#) $Id: tclCmdMZ.c,v 1.82.2.21 2005/10/23 22:01:29 msofer Exp $ */ #include "tclInt.h" @@ -461,9 +461,10 @@ Tcl_RegexpObjCmd(dummy, interp, objc, objv) } } else { Tcl_Obj *valuePtr; + Tcl_IncrRefCount(newPtr); valuePtr = Tcl_ObjSetVar2(interp, objv[i], NULL, newPtr, 0); + Tcl_DecrRefCount(newPtr); if (valuePtr == NULL) { - Tcl_DecrRefCount(newPtr); Tcl_AppendResult(interp, "couldn't set variable \"", Tcl_GetString(objv[i]), "\"", (char *) NULL); return TCL_ERROR; @@ -1758,10 +1759,16 @@ Tcl_StringObjCmd(dummy, interp, objc, objv) * Only set the failVarObj when we will return 0 * and we have indicated a valid fail index (>= 0) */ - if ((result == 0) && (failVarObj != NULL) && - Tcl_ObjSetVar2(interp, failVarObj, NULL, Tcl_NewIntObj(failat), - TCL_LEAVE_ERR_MSG) == NULL) { - return TCL_ERROR; + if ((result == 0) && (failVarObj != NULL)) { + Tcl_Obj *resPtr, *tmpPtr = Tcl_NewIntObj(failat); + + Tcl_IncrRefCount(tmpPtr); + resPtr = Tcl_ObjSetVar2(interp, failVarObj, NULL, tmpPtr, + TCL_LEAVE_ERR_MSG); + Tcl_DecrRefCount(tmpPtr); + if (resPtr == NULL) { + return TCL_ERROR; + } } Tcl_SetBooleanObj(resultPtr, result); break; |