1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-01-11 05:17:37 +03:00

Add missing argument checks for new API functions

This commit is contained in:
Nick Wellnhofer 2024-06-12 13:32:32 +02:00
parent 8318b5a634
commit 4467b89143
3 changed files with 16 additions and 4 deletions

View File

@ -136,6 +136,9 @@ xmlCtxtErrMemory(xmlParserCtxtPtr ctxt)
xmlGenericErrorFunc channel = NULL;
void *data;
if (ctxt == NULL)
return;
ctxt->errNo = XML_ERR_NO_MEMORY;
ctxt->instate = XML_PARSER_EOF; /* TODO: Remove after refactoring */
ctxt->wellFormed = 0;
@ -1141,6 +1144,9 @@ xmlSwitchInputEncodingName(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
*/
int
xmlSwitchEncodingName(xmlParserCtxtPtr ctxt, const char *encoding) {
if (ctxt == NULL)
return(-1);
return(xmlSwitchInputEncodingName(ctxt, ctxt->input, encoding));
}

View File

@ -2276,6 +2276,9 @@ xmlPatternCompileSafe(const xmlChar *pattern, xmlDict *dict, int flags,
int streamable = 1;
int error;
if (patternOut == NULL)
return(1);
if (pattern == NULL) {
error = 1;
goto error;

11
uri.c
View File

@ -980,8 +980,9 @@ xmlParseURISafe(const char *str, xmlURIPtr *uriOut) {
xmlURIPtr uri;
int ret;
if (uriOut != NULL)
*uriOut = NULL;
if (uriOut == NULL)
return(1);
*uriOut = NULL;
if (str == NULL)
return(1);
@ -995,8 +996,7 @@ xmlParseURISafe(const char *str, xmlURIPtr *uriOut) {
return(ret);
}
if (uriOut != NULL)
*uriOut = uri;
*uriOut = uri;
return(0);
}
@ -2016,6 +2016,9 @@ xmlBuildURISafe(const xmlChar *URI, const xmlChar *base, xmlChar **valPtr) {
xmlURIPtr bas = NULL;
xmlURIPtr res = NULL;
if (valPtr == NULL)
return(1);
/*
* 1) The URI reference is parsed into the potential four components and
* fragment identifier, as described in Section 4.3.