diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | generic/tclDictObj.c | 16 | ||||
-rw-r--r-- | tests/dict.test | 4 |
3 files changed, 16 insertions, 17 deletions
@@ -1,6 +1,13 @@ +2012-01-22 Donal K. Fellows <dkf@users.sf.net> + + * generic/tclDictObj.c (DictExistsCmd): [Bug 3475264]: Ensure that + errors only ever happen when insufficient arguments are supplied, and + not when a path doesn't exist or a dictionary is poorly formatted (the + two cases can't be easily distinguished). + 2012-01-21 Jan Nijtmans <nijtmans@users.sf.net> - * generic/tcl.h: [Bug-3474726]: Eliminate detection of struct + * generic/tcl.h: [Bug 3474726]: Eliminate detection of struct * generic/tclWinPort.h: _stat32i64, just use _stati64 in combination * generic/tclFCmd.c: with _USE_32BIT_TIME_T, which is the same then. * generic/tclTest.c: Only keep _stat32i64 usage for cygwin, so it @@ -9,7 +16,7 @@ 2012-01-21 Don Porter <dgp@users.sourceforge.net> - * generic/tclCmdMZ.c: [Bug 3475667] Prevent buffer read overflow. + * generic/tclCmdMZ.c: [Bug 3475667]: Prevent buffer read overflow. Thanks to "sebres" for the report and fix. 2012-01-17 Donal K. Fellows <dkf@users.sf.net> @@ -31,7 +38,7 @@ 2012-01-09 Jan Nijtmans <nijtmans@users.sf.net> - * generic/tclUtf.c: [Bug 3464428] string is graph \u0120 is wrong + * generic/tclUtf.c: [Bug 3464428]: string is graph \u0120 is wrong * generic/regc_locale.c: Add table for Unicode [:cntrl:] class * tools/uniClass.tcl: Generate Unicode [:cntrl:] class table * tests/utf.test: diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index 06c5754..03c4d67 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -1969,7 +1969,6 @@ DictExistsCmd( Tcl_Obj *const *objv) { Tcl_Obj *dictPtr, *valuePtr; - int result; if (objc < 3) { Tcl_WrongNumArgs(interp, 1, objv, "dictionary key ?key ...?"); @@ -1978,18 +1977,13 @@ DictExistsCmd( dictPtr = TclTraceDictPath(interp, objv[1], objc-3, objv+2, DICT_PATH_EXISTS); - if (dictPtr == NULL) { - return TCL_ERROR; - } - if (dictPtr == DICT_PATH_NON_EXISTENT) { + if (dictPtr == NULL || dictPtr == DICT_PATH_NON_EXISTENT + || Tcl_DictObjGet(interp, dictPtr, objv[objc-1], + &valuePtr) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewBooleanObj(0)); - return TCL_OK; - } - result = Tcl_DictObjGet(interp, dictPtr, objv[objc-1], &valuePtr); - if (result != TCL_OK) { - return result; + } else { + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(valuePtr != NULL)); } - Tcl_SetObjResult(interp, Tcl_NewBooleanObj(valuePtr != NULL)); return TCL_OK; } diff --git a/tests/dict.test b/tests/dict.test index cfaf36d..5821c32 100644 --- a/tests/dict.test +++ b/tests/dict.test @@ -222,9 +222,7 @@ test dict-9.2 {dict exists command} {dict exists {a b} b} 0 test dict-9.3 {dict exists command} {dict exists {a {b c}} a b} 1 test dict-9.4 {dict exists command} {dict exists {a {b c}} a c} 0 test dict-9.5 {dict exists command} {dict exists {a {b c}} b c} 0 -test dict-9.6 {dict exists command} { - list [catch {dict exists {a {b c d}} a c} msg] $msg -} {1 {missing value to go with key}} +test dict-9.6 {dict exists command} {dict exists {a {b c d}} a c} 0 test dict-9.7 {dict exists command} { list [catch {dict exists} msg] $msg } {1 {wrong # args: should be "dict exists dictionary key ?key ...?"}} |