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/tclBinary.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/tclBinary.c')
-rw-r--r-- | generic/tclBinary.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c index cf83b99..fcc0061 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.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: tclBinary.c,v 1.13.2.3 2005/09/27 15:44:13 dkf Exp $ + * RCS: @(#) $Id: tclBinary.c,v 1.13.2.4 2005/10/23 22:01:29 msofer Exp $ */ #include "tclInt.h" @@ -1083,12 +1083,13 @@ Tcl_BinaryObjCmd(dummy, interp, objc, objv) } } valuePtr = Tcl_NewByteArrayObj(src, size); + Tcl_IncrRefCount(valuePtr); resultPtr = Tcl_ObjSetVar2(interp, objv[arg], NULL, valuePtr, TCL_LEAVE_ERR_MSG); + Tcl_DecrRefCount(valuePtr); arg++; if (resultPtr == NULL) { DeleteScanNumberCache(numberCachePtr); - Tcl_DecrRefCount(valuePtr); /* unneeded */ return TCL_ERROR; } offset += count; @@ -1137,13 +1138,14 @@ Tcl_BinaryObjCmd(dummy, interp, objc, objv) *dest++ = (char) ((value & 0x80) ? '1' : '0'); } } - + + Tcl_IncrRefCount(valuePtr); resultPtr = Tcl_ObjSetVar2(interp, objv[arg], NULL, valuePtr, TCL_LEAVE_ERR_MSG); + Tcl_DecrRefCount(valuePtr); arg++; if (resultPtr == NULL) { DeleteScanNumberCache(numberCachePtr); - Tcl_DecrRefCount(valuePtr); /* unneeded */ return TCL_ERROR; } offset += (count + 7 ) / 8; @@ -1195,12 +1197,13 @@ Tcl_BinaryObjCmd(dummy, interp, objc, objv) } } + Tcl_IncrRefCount(valuePtr); resultPtr = Tcl_ObjSetVar2(interp, objv[arg], NULL, valuePtr, TCL_LEAVE_ERR_MSG); + Tcl_DecrRefCount(valuePtr); arg++; if (resultPtr == NULL) { DeleteScanNumberCache(numberCachePtr); - Tcl_DecrRefCount(valuePtr); /* unneeded */ return TCL_ERROR; } offset += (count + 1) / 2; @@ -1266,12 +1269,13 @@ Tcl_BinaryObjCmd(dummy, interp, objc, objv) offset += count*size; } + Tcl_IncrRefCount(valuePtr); resultPtr = Tcl_ObjSetVar2(interp, objv[arg], NULL, valuePtr, TCL_LEAVE_ERR_MSG); + Tcl_DecrRefCount(valuePtr); arg++; if (resultPtr == NULL) { DeleteScanNumberCache(numberCachePtr); - Tcl_DecrRefCount(valuePtr); /* unneeded */ return TCL_ERROR; } break; |