summaryrefslogtreecommitdiffstats
path: root/generic/tclDictObj.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-01-22 13:08:15 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-01-22 13:08:15 (GMT)
commitd40680de05ee6071b6e4579157be4d7947a53ddd (patch)
treea9b17a915c64cabe839d46f2d245253603f390fb /generic/tclDictObj.c
parent4aed2bc2cd16fef4ffe748ec35725686038a4fbb (diff)
downloadtcl-d40680de05ee6071b6e4579157be4d7947a53ddd.zip
tcl-d40680de05ee6071b6e4579157be4d7947a53ddd.tar.gz
tcl-d40680de05ee6071b6e4579157be4d7947a53ddd.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.c16
1 files changed, 5 insertions, 11 deletions
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;
}