Ticket Hash: | 97c0994ae4aa90531b2929e2d64189ccaec444ff | |||
Title: | selectNodes -cache 1 and a syntactically incorrect xPath statement | |||
Status: | Closed | Type: | Code_Defect | |
Severity: | Important | Priority: | Immediate | |
Subsystem: | Resolution: | Fixed | ||
Last Modified: | 2017-06-16 00:37:05 | |||
Version Found In: | head | |||
User Comments: | ||||
anonymous added on 2017-06-15 16:37:17:
(text/x-fossil-wiki)
with [selectNodes -cache 1], when a syntactically-invalid XPath expression is used twice, no error is raised the second time, and an empty expression is used by xPathEval. Here is a patch: <code><verbatim> Index: generic/domxpath.c ================================================================== --- generic/domxpath.c +++ generic/domxpath.c @@ -5187,20 +5187,25 @@ ) { xpathResultSet nodeList; int rc, hnew = 1, docOrder = 1; ast t; - Tcl_HashEntry *h; + Tcl_HashEntry *h = NULL; *errMsg = NULL; if (cache) { h = Tcl_CreateHashEntry (cache, xpath, &hnew); } if (hnew) { rc = xpathParse(xpath, exprContext, XPATH_EXPR, prefixMappings, parseVarCB, &t, errMsg); - CHECK_RC; + if (rc) { + if (h != NULL) { + Tcl_DeleteHashEntry(h); + } + return rc; + } if (cache) { Tcl_SetHashValue(h, t); } } else { t = (ast)Tcl_GetHashValue(h); </verbatim></code> rolf added on 2017-06-16 00:36:27: (text/x-fossil-plain) You're right. Fix applied. Thanks. |