diff --git a/parserInternals.c b/parserInternals.c index a2fe5aad..6a43cc8f 100644 --- a/parserInternals.c +++ b/parserInternals.c @@ -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)); } diff --git a/pattern.c b/pattern.c index 2b669768..23b52744 100644 --- a/pattern.c +++ b/pattern.c @@ -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; diff --git a/uri.c b/uri.c index 3803e0de..370b449f 100644 --- a/uri.c +++ b/uri.c @@ -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.