malloc-fail: Fix error check in xmlXPathCompareValues

Avoid null deref.

Found with libFuzzer, see #344.
This commit is contained in:
Nick Wellnhofer 2023-01-30 15:48:11 +01:00
parent 755344013e
commit 621c222efe

12
xpath.c
View File

@ -7408,21 +7408,13 @@ xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict) {
valuePush(ctxt, arg1);
xmlXPathNumberFunction(ctxt, 1);
arg1 = valuePop(ctxt);
}
if (arg1->type != XPATH_NUMBER) {
xmlXPathFreeObject(arg1);
xmlXPathFreeObject(arg2);
XP_ERROR0(XPATH_INVALID_OPERAND);
CHECK_ERROR0;
}
if (arg2->type != XPATH_NUMBER) {
valuePush(ctxt, arg2);
xmlXPathNumberFunction(ctxt, 1);
arg2 = valuePop(ctxt);
}
if (arg2->type != XPATH_NUMBER) {
xmlXPathReleaseObject(ctxt->context, arg1);
xmlXPathReleaseObject(ctxt->context, arg2);
XP_ERROR0(XPATH_INVALID_OPERAND);
CHECK_ERROR0;
}
/*
* Add tests for infinity and nan