diff options
author | dgp <dgp@users.sourceforge.net> | 2010-03-24 15:31:47 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2010-03-24 15:31:47 (GMT) |
commit | 1adcd44891a492ada9ee28225979deeec480398c (patch) | |
tree | e35f7fbdcbeefd2d46ec87a195405c4187d5d740 | |
parent | b199de25aaa631078acc7cd5e5f562d7c46485f3 (diff) | |
download | tcl-1adcd44891a492ada9ee28225979deeec480398c.zip tcl-1adcd44891a492ada9ee28225979deeec480398c.tar.gz tcl-1adcd44891a492ada9ee28225979deeec480398c.tar.bz2 |
* generic/tclResult.c: [Bug 2383005] Revise [return -errorcode] so
* tests/result.test: that it rejects illegal non-list values.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tclResult.c | 22 | ||||
-rw-r--r-- | tests/result.test | 6 |
3 files changed, 30 insertions, 3 deletions
@@ -1,3 +1,8 @@ +2010-03-24 Don Porter <dgp@users.sourceforge.net> + + * generic/tclResult.c: [Bug 2383005] Revise [return -errorcode] so + * tests/result.test: that it rejects illegal non-list values. + 2010-03-20 Donal K. Fellows <dkf@users.sf.net> * generic/tclIO.c (CopyData): Allow the total number of bytes copied diff --git a/generic/tclResult.c b/generic/tclResult.c index 054ba9d..c461387 100644 --- a/generic/tclResult.c +++ b/generic/tclResult.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclResult.c,v 1.47 2008/03/07 22:42:49 andreas_kupries Exp $ + * RCS: @(#) $Id: tclResult.c,v 1.47.2.1 2010/03/24 15:31:48 dgp Exp $ */ #include "tclInt.h" @@ -1379,6 +1379,26 @@ TclMergeReturnOptions( } /* + * Check for bogus -errorcode value. + */ + + Tcl_DictObjGet(NULL, returnOpts, keys[KEY_ERRORCODE], &valuePtr); + if (valuePtr != NULL) { + int length; + + if (TCL_ERROR == Tcl_ListObjLength(NULL, valuePtr, &length )) { + /* + * Value is not a list, which is illegal for -errorcode. + */ + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "bad -errorcode value: " + "expected a list but got \"", + TclGetString(valuePtr), "\"", NULL); + goto error; + } + } + + /* * Convert [return -code return -level X] to [return -code ok -level X+1] */ diff --git a/tests/result.test b/tests/result.test index cefcaed..8573217 100644 --- a/tests/result.test +++ b/tests/result.test @@ -132,8 +132,10 @@ test result-6.2 {Bug 1649062} -setup { } -cleanup { rename foo {} } -result {foo {} {}} - - +test result-6.3 {Bug 2383005} { + catch {return -code error -errorcode {{}a} eek} m + set m +} {bad -errorcode value: expected a list but got "{}a"} # cleanup cleanupTests return |