summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2002-06-25 08:59:35 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2002-06-25 08:59:35 (GMT)
commit7ca07353686f0823109480f1f02842e4aa6491ae (patch)
tree93e9561c5d2d5d2788c9b6e588573abee06f4589
parenteca141d09f28440e73a5f323d01499837bbe4e9d (diff)
downloadtcl-7ca07353686f0823109480f1f02842e4aa6491ae.zip
tcl-7ca07353686f0823109480f1f02842e4aa6491ae.tar.gz
tcl-7ca07353686f0823109480f1f02842e4aa6491ae.tar.bz2
Surface fix for bug #533364; TclGetIntForIndex no longer assumes an unshared
empty result when generating an error message.
-rw-r--r--ChangeLog10
-rw-r--r--generic/tclUtil.c16
2 files changed, 22 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index db05d56..fd2193e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2002-06-25 Donal K. Fellows <fellowsd@cs.man.ac.uk>
+
+ * generic/tclUtil.c (TclGetIntForIndex): Fix of critical bug
+ #533364 generated when the index is bad and the result is a shared
+ object. The T_ASTO(T_GOR, ...) idiom likely exists elsewhere
+ though. Also removed some cruft that just complicated things to
+ no advantage.
+ (SetEndOffsetFromAny): Same fix, though this wasn't on the path
+ excited by the bug.
+
2002-06-24 Don Porter <dgp@users.sourceforge.net>
* library/tcltest/tcltest.tcl: Implementation of TIP 101. Adds
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index b83c7c8..ff5e53a 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUtil.c,v 1.31 2002/04/19 13:08:56 dkf Exp $
+ * RCS: @(#) $Id: tclUtil.c,v 1.32 2002/06/25 08:59:36 dkf Exp $
*/
#include "tclInt.h"
@@ -2197,7 +2197,7 @@ TclGetIntForIndex(interp, objPtr, endValue, indexPtr)
* representing an index. */
{
char *bytes;
- int length, offset;
+ int offset;
#ifndef TCL_WIDE_INT_IS_LONG
Tcl_WideInt wideOffset;
#endif
@@ -2267,8 +2267,14 @@ TclGetIntForIndex(interp, objPtr, endValue, indexPtr)
* Report a parse error.
*/
- if ((Interp *)interp != NULL) {
- bytes = Tcl_GetStringFromObj(objPtr, &length);
+ if (interp != NULL) {
+ bytes = Tcl_GetString(objPtr);
+ /*
+ * The result might not be empty; this resets it which
+ * should be both a cheap operation, and of little problem
+ * because this is an error-generation path anyway.
+ */
+ Tcl_ResetResult(interp);
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"bad index \"", bytes,
"\": must be integer or end?-integer?",
@@ -2365,6 +2371,7 @@ SetEndOffsetFromAny(interp, objPtr)
if ((*bytes != 'e') || (strncmp(bytes, "end",
(size_t)((length > 3) ? 3 : length)) != 0)) {
if (interp != NULL) {
+ Tcl_ResetResult(interp);
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"bad index \"", bytes,
"\": must be end?-integer?",
@@ -2390,6 +2397,7 @@ SetEndOffsetFromAny(interp, objPtr)
* Conversion failed. Report the error.
*/
if (interp != NULL) {
+ Tcl_ResetResult(interp);
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"bad index \"", bytes,
"\": must be integer or end?-integer?",