diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | generic/tclDictObj.c | 16 | ||||
-rw-r--r-- | tests/dict.test | 4 |
3 files changed, 15 insertions, 16 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> diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index d50c0a2..ac2cb62 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -1982,7 +1982,6 @@ DictExistsCmd( Tcl_Obj *const *objv) { Tcl_Obj *dictPtr, *valuePtr; - int result; if (objc < 3) { Tcl_WrongNumArgs(interp, 1, objv, "dictionary key ?key ...?"); @@ -1991,18 +1990,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 87e5107..5a2b609 100644 --- a/tests/dict.test +++ b/tests/dict.test @@ -214,9 +214,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} -returnCodes error -body { - dict exists {a {b c d}} a c -} -result {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} -returnCodes error -body { dict exists } -result {wrong # args: should be "dict exists dictionary key ?key ...?"} |