Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit 4467b89

Browse files
committed
Add missing argument checks for new API functions
1 parent 8318b5a commit 4467b89

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

parserInternals.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ xmlCtxtErrMemory(xmlParserCtxtPtr ctxt)
136136
xmlGenericErrorFunc channel = NULL;
137137
void *data;
138138

139+
if (ctxt == NULL)
140+
return;
141+
139142
ctxt->errNo = XML_ERR_NO_MEMORY;
140143
ctxt->instate = XML_PARSER_EOF; /* TODO: Remove after refactoring */
141144
ctxt->wellFormed = 0;
@@ -1141,6 +1144,9 @@ xmlSwitchInputEncodingName(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
11411144
*/
11421145
int
11431146
xmlSwitchEncodingName(xmlParserCtxtPtr ctxt, const char *encoding) {
1147+
if (ctxt == NULL)
1148+
return(-1);
1149+
11441150
return(xmlSwitchInputEncodingName(ctxt, ctxt->input, encoding));
11451151
}
11461152

pattern.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,6 +2276,9 @@ xmlPatternCompileSafe(const xmlChar *pattern, xmlDict *dict, int flags,
22762276
int streamable = 1;
22772277
int error;
22782278

2279+
if (patternOut == NULL)
2280+
return(1);
2281+
22792282
if (pattern == NULL) {
22802283
error = 1;
22812284
goto error;

uri.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -980,8 +980,9 @@ xmlParseURISafe(const char *str, xmlURIPtr *uriOut) {
980980
xmlURIPtr uri;
981981
int ret;
982982

983-
if (uriOut != NULL)
984-
*uriOut = NULL;
983+
if (uriOut == NULL)
984+
return(1);
985+
*uriOut = NULL;
985986
if (str == NULL)
986987
return(1);
987988

@@ -995,8 +996,7 @@ xmlParseURISafe(const char *str, xmlURIPtr *uriOut) {
995996
return(ret);
996997
}
997998

998-
if (uriOut != NULL)
999-
*uriOut = uri;
999+
*uriOut = uri;
10001000
return(0);
10011001
}
10021002

@@ -2016,6 +2016,9 @@ xmlBuildURISafe(const xmlChar *URI, const xmlChar *base, xmlChar **valPtr) {
20162016
xmlURIPtr bas = NULL;
20172017
xmlURIPtr res = NULL;
20182018

2019+
if (valPtr == NULL)
2020+
return(1);
2021+
20192022
/*
20202023
* 1) The URI reference is parsed into the potential four components and
20212024
* fragment identifier, as described in Section 4.3.

0 commit comments

Comments
 (0)