diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-01-22 13:16:06 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-01-22 13:16:06 (GMT) |
commit | edc866e029899e5fc2a23621625b1a3199f9aac5 (patch) | |
tree | d225dfaed141a4070f1a15889cb6b1555e9c99b7 /generic/tclDictObj.c | |
parent | 90f7079c2b9adf22d6c3cbb162df3fc985707528 (diff) | |
parent | d40680de05ee6071b6e4579157be4d7947a53ddd (diff) | |
download | tcl-edc866e029899e5fc2a23621625b1a3199f9aac5.zip tcl-edc866e029899e5fc2a23621625b1a3199f9aac5.tar.gz tcl-edc866e029899e5fc2a23621625b1a3199f9aac5.tar.bz2 |
* 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).
Diffstat (limited to 'generic/tclDictObj.c')
-rw-r--r-- | generic/tclDictObj.c | 16 |
1 files changed, 5 insertions, 11 deletions
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; } |