summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2010-03-24 15:33:14 (GMT)
committerdgp <dgp@users.sourceforge.net>2010-03-24 15:33:14 (GMT)
commitf39f64f06bbce181e06855f40981b19669febdd0 (patch)
tree916c3774dcc8cfaed6cbd2a22ca2ff106e8dbb37
parent188c38659bf0d5e51f7263d592af87cd8c753a17 (diff)
downloadtcl-f39f64f06bbce181e06855f40981b19669febdd0.zip
tcl-f39f64f06bbce181e06855f40981b19669febdd0.tar.gz
tcl-f39f64f06bbce181e06855f40981b19669febdd0.tar.bz2
* generic/tclResult.c: [Bug 2383005] Revise [return -errorcode] so
* tests/result.test: that it rejects illegal non-list values.
-rw-r--r--generic/tclResult.c24
-rw-r--r--tests/result.test5
2 files changed, 27 insertions, 2 deletions
diff --git a/generic/tclResult.c b/generic/tclResult.c
index 273416d..3c329f1 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.57 2010/02/24 10:45:04 dkf Exp $
+ * RCS: @(#) $Id: tclResult.c,v 1.58 2010/03/24 15:33:14 dgp Exp $
*/
#include "tclInt.h"
@@ -1425,6 +1425,28 @@ 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);
+ Tcl_SetErrorCode(interp, "TCL", "RESULT", "ILLEGAL_ERRORCODE",
+ 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 95407b9..b2db8ec 100644
--- a/tests/result.test
+++ b/tests/result.test
@@ -131,7 +131,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