1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-25 10:50:08 +03:00

xmllint: Report malloc failures from parsing patterns

This commit is contained in:
Nick Wellnhofer 2025-01-17 18:13:35 +01:00
parent 255fd5f3f1
commit bf1d8b9cfb

View File

@ -3405,12 +3405,16 @@ xmllintMain(int argc, const char **argv, FILE *errStream,
#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED)
if ((lint->pattern != NULL) && (lint->walker == 0)) {
lint->patternc = xmlPatterncompile(BAD_CAST lint->pattern, NULL, 0,
NULL);
res = xmlPatternCompileSafe(BAD_CAST lint->pattern, NULL, 0, NULL,
&lint->patternc);
if (lint->patternc == NULL) {
fprintf(errStream, "Pattern %s failed to compile\n",
lint->pattern);
lint->progresult = XMLLINT_ERR_SCHEMAPAT;
if (res < 0) {
lint->progresult = XMLLINT_ERR_MEM;
} else {
fprintf(errStream, "Pattern %s failed to compile\n",
lint->pattern);
lint->progresult = XMLLINT_ERR_SCHEMAPAT;
}
goto error;
}
}