* xmlXPathCheckOpLimit: * @ctxt: the XPath Parser context * @opCount: the number of operations to be added * * Adds opCount to the running total of operations and returns -1 if the * operation limit is exceeded. Returns 0 otherwise. */
| 744 | * operation limit is exceeded. Returns 0 otherwise. |
| 745 | */ |
| 746 | static int |
| 747 | xmlXPathCheckOpLimit(xmlXPathParserContextPtr ctxt, unsigned long opCount) { |
| 748 | xmlXPathContextPtr xpctxt = ctxt->context; |
| 749 | |
| 750 | if ((opCount > xpctxt->opLimit) || |
| 751 | (xpctxt->opCount > xpctxt->opLimit - opCount)) { |
| 752 | xpctxt->opCount = xpctxt->opLimit; |
| 753 | xmlXPathErr(ctxt, XPATH_OP_LIMIT_EXCEEDED); |
| 754 | return(-1); |
| 755 | } |
| 756 | |
| 757 | xpctxt->opCount += opCount; |
| 758 | return(0); |
| 759 | } |
| 760 | |
| 761 | #define OP_LIMIT_EXCEEDED(ctxt, n) \ |
| 762 | ((ctxt->context->opLimit != 0) && (xmlXPathCheckOpLimit(ctxt, n) < 0)) |
no test coverage detected