mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2024-10-26 12:25:09 +03:00
autogenerate a minimal NULL value sequence for unknown pointer types This
* gentest.py testapi.c: autogenerate a minimal NULL value sequence for unknown pointer types * HTMLparser.c SAX2.c chvalid.c encoding.c entities.c parser.c parserInternals.c relaxng.c valid.c xmlIO.c xmlreader.c xmlsave.c xmlschemas.c xmlschemastypes.c xmlstring.c xpath.c xpointer.c: This uncovered an impressive amount of entry points not checking for NULL pointers when they ought to, closing all the open gaps. Daniel
This commit is contained in:
parent
b031cef5b5
commit
ce682bc24b
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
Fri Nov 5 18:19:23 CET 2004 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* gentest.py testapi.c: autogenerate a minimal NULL value sequence
|
||||
for unknown pointer types
|
||||
* HTMLparser.c SAX2.c chvalid.c encoding.c entities.c parser.c
|
||||
parserInternals.c relaxng.c valid.c xmlIO.c xmlreader.c
|
||||
xmlsave.c xmlschemas.c xmlschemastypes.c xmlstring.c xpath.c
|
||||
xpointer.c: This uncovered an impressive amount of entry points
|
||||
not checking for NULL pointers when they ought to, closing all
|
||||
the open gaps.
|
||||
|
||||
Fri Nov 5 16:26:28 UTC 2004 William Brack <wbrack@mmm.com.hk>
|
||||
|
||||
* catalog.c: fixed problem with NULL entry (bug 157407)
|
||||
|
@ -1794,6 +1794,7 @@ UTF8ToHtml(unsigned char* out, int *outlen,
|
||||
unsigned int c, d;
|
||||
int trailing;
|
||||
|
||||
if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
|
||||
if (in == NULL) {
|
||||
/*
|
||||
* initialization nothing to do
|
||||
@ -1888,13 +1889,17 @@ int
|
||||
htmlEncodeEntities(unsigned char* out, int *outlen,
|
||||
const unsigned char* in, int *inlen, int quoteChar) {
|
||||
const unsigned char* processed = in;
|
||||
const unsigned char* outend = out + (*outlen);
|
||||
const unsigned char* outend;
|
||||
const unsigned char* outstart = out;
|
||||
const unsigned char* instart = in;
|
||||
const unsigned char* inend = in + (*inlen);
|
||||
const unsigned char* inend;
|
||||
unsigned int c, d;
|
||||
int trailing;
|
||||
|
||||
if ((out == NULL) || (outlen == NULL) || (inlen == NULL) || (in == NULL))
|
||||
return(-1);
|
||||
outend = out + (*outlen);
|
||||
inend = in + (*inlen);
|
||||
while (in < inend) {
|
||||
d = *in++;
|
||||
if (d < 0x80) { c= d; trailing= 0; }
|
||||
|
2
SAX2.c
2
SAX2.c
@ -1423,7 +1423,7 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"SAX.xmlSAX2StartElement(%s)\n", fullname);
|
||||
#endif
|
||||
if (ctx == NULL) return;
|
||||
if ((ctx == NULL) || (fullname == NULL)) return;
|
||||
|
||||
/*
|
||||
* First check on validity:
|
||||
|
@ -166,6 +166,8 @@ xmlCharInRange (unsigned int val, const xmlChRangeGroupPtr rptr) {
|
||||
int low, high, mid;
|
||||
xmlChSRangePtr sptr;
|
||||
xmlChLRangePtr lptr;
|
||||
|
||||
if (rptr == NULL) return(0);
|
||||
if (val < 0x10000) { /* is val in 'short' or 'long' array? */
|
||||
if (rptr->nbShortRange == 0)
|
||||
return 0;
|
||||
|
39
encoding.c
39
encoding.c
@ -155,6 +155,7 @@ UTF8Toascii(unsigned char* out, int *outlen,
|
||||
unsigned int c, d;
|
||||
int trailing;
|
||||
|
||||
if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
|
||||
if (in == NULL) {
|
||||
/*
|
||||
* initialization nothing to do
|
||||
@ -232,10 +233,14 @@ isolat1ToUTF8(unsigned char* out, int *outlen,
|
||||
const unsigned char* in, int *inlen) {
|
||||
unsigned char* outstart = out;
|
||||
const unsigned char* base = in;
|
||||
unsigned char* outend = out + *outlen;
|
||||
unsigned char* outend;
|
||||
const unsigned char* inend;
|
||||
const unsigned char* instop;
|
||||
|
||||
if ((out == NULL) || (in == NULL) || (outlen == NULL) || (inlen == NULL))
|
||||
return(-1);
|
||||
|
||||
outend = out + *outlen;
|
||||
inend = in + (*inlen);
|
||||
instop = inend;
|
||||
|
||||
@ -322,6 +327,7 @@ UTF8Toisolat1(unsigned char* out, int *outlen,
|
||||
unsigned int c, d;
|
||||
int trailing;
|
||||
|
||||
if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
|
||||
if (in == NULL) {
|
||||
/*
|
||||
* initialization nothing to do
|
||||
@ -503,6 +509,7 @@ UTF8ToUTF16LE(unsigned char* outb, int *outlen,
|
||||
unsigned short tmp1, tmp2;
|
||||
|
||||
/* UTF16LE encoding has no BOM */
|
||||
if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
|
||||
if (in == NULL) {
|
||||
*outlen = 0;
|
||||
*inlen = 0;
|
||||
@ -743,6 +750,7 @@ UTF8ToUTF16BE(unsigned char* outb, int *outlen,
|
||||
unsigned short tmp1, tmp2;
|
||||
|
||||
/* UTF-16BE has no BOM */
|
||||
if ((outb == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
|
||||
if (in == NULL) {
|
||||
*outlen = 0;
|
||||
*inlen = 0;
|
||||
@ -839,6 +847,8 @@ UTF8ToUTF16BE(unsigned char* outb, int *outlen,
|
||||
xmlCharEncoding
|
||||
xmlDetectCharEncoding(const unsigned char* in, int len)
|
||||
{
|
||||
if (in == NULL)
|
||||
return(XML_CHAR_ENCODING_NONE);
|
||||
if (len >= 4) {
|
||||
if ((in[0] == 0x00) && (in[1] == 0x00) &&
|
||||
(in[2] == 0x00) && (in[3] == 0x3C))
|
||||
@ -1653,15 +1663,17 @@ xmlFindCharEncodingHandler(const char *name) {
|
||||
* The value of @outlen after return is the number of ocetes consumed.
|
||||
*/
|
||||
static int
|
||||
xmlIconvWrapper(iconv_t cd,
|
||||
unsigned char *out, int *outlen,
|
||||
const unsigned char *in, int *inlen) {
|
||||
|
||||
size_t icv_inlen = *inlen, icv_outlen = *outlen;
|
||||
xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
|
||||
const unsigned char *in, int *inlen) {
|
||||
size_t icv_inlen, icv_outlen;
|
||||
const char *icv_in = (const char *) in;
|
||||
char *icv_out = (char *) out;
|
||||
int ret;
|
||||
|
||||
if ((out == NULL) || (outlen == NULL) || (inlen == NULL) || (in == NULL))
|
||||
return(-1);
|
||||
icv_inlen = *inlen;
|
||||
icv_outlen = *outlen;
|
||||
ret = iconv(cd, (char **) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
|
||||
if (in != NULL) {
|
||||
*inlen -= icv_inlen;
|
||||
@ -2203,6 +2215,9 @@ UTF8ToISO8859x(unsigned char* out, int *outlen,
|
||||
const unsigned char* inend;
|
||||
const unsigned char* instart = in;
|
||||
|
||||
if ((out == NULL) || (outlen == NULL) || (inlen == NULL) ||
|
||||
(xlattable == NULL))
|
||||
return(-1);
|
||||
if (in == NULL) {
|
||||
/*
|
||||
* initialization nothing to do
|
||||
@ -2311,12 +2326,18 @@ ISO8859xToUTF8(unsigned char* out, int *outlen,
|
||||
const unsigned char* in, int *inlen,
|
||||
unsigned short const *unicodetable) {
|
||||
unsigned char* outstart = out;
|
||||
unsigned char* outend = out + *outlen;
|
||||
unsigned char* outend;
|
||||
const unsigned char* instart = in;
|
||||
const unsigned char* inend = in + *inlen;
|
||||
const unsigned char* inend;
|
||||
const unsigned char* instop = inend;
|
||||
unsigned int c = *in;
|
||||
unsigned int c;
|
||||
|
||||
if ((out == NULL) || (outlen == NULL) || (inlen == NULL) ||
|
||||
(in == NULL) || (xlattable == NULL))
|
||||
return(-1);
|
||||
outend = out + *outlen;
|
||||
inend = in + *inlen;
|
||||
c = *in;
|
||||
while (in < inend && out < outend - 1) {
|
||||
if (c >= 0x80) {
|
||||
c = unicodetable [c - 0x80];
|
||||
|
@ -815,6 +815,7 @@ xmlDumpEntityContent(xmlBufferPtr buf, const xmlChar *content) {
|
||||
*/
|
||||
void
|
||||
xmlDumpEntityDecl(xmlBufferPtr buf, xmlEntityPtr ent) {
|
||||
if ((buf == NULL) || (ent == NULL)) return;
|
||||
switch (ent->etype) {
|
||||
case XML_INTERNAL_GENERAL_ENTITY:
|
||||
xmlBufferWriteChar(buf, "<!ENTITY ");
|
||||
|
45
gentest.py
45
gentest.py
@ -72,6 +72,10 @@ extra_pre_call = {
|
||||
"if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;",
|
||||
"xmlSAXUserParseMemory":
|
||||
"if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;",
|
||||
"xmlParseBalancedChunkMemory":
|
||||
"if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;",
|
||||
"xmlParseBalancedChunkMemoryRecover":
|
||||
"if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;",
|
||||
}
|
||||
extra_post_call = {
|
||||
"xmlAddChild":
|
||||
@ -145,6 +149,14 @@ def add_missing_type(name, func):
|
||||
except:
|
||||
missing_types[name] = [func]
|
||||
|
||||
generated_param_types = []
|
||||
def add_generated_param_type(name):
|
||||
generated_param_types.append(name)
|
||||
|
||||
generated_return_types = []
|
||||
def add_generated_return_type(name):
|
||||
generated_return_types.append(name)
|
||||
|
||||
missing_functions = {}
|
||||
missing_functions_nr = 0
|
||||
def add_missing_functions(name, module):
|
||||
@ -216,10 +228,32 @@ def type_convert(str, name, info, module, function, pos):
|
||||
|
||||
known_param_types = []
|
||||
|
||||
def is_known_param_type(name):
|
||||
def is_known_param_type(name, rtype):
|
||||
global test
|
||||
for type in known_param_types:
|
||||
if type == name:
|
||||
return 1
|
||||
for type in generated_param_types:
|
||||
if type == name:
|
||||
return 1
|
||||
|
||||
if name[-3:] == 'Ptr' or name[-4:] == '_ptr':
|
||||
if rtype[0:6] == 'const ':
|
||||
crtype = rtype[6:]
|
||||
else:
|
||||
crtype = rtype
|
||||
|
||||
test.write("""
|
||||
#define gen_nb_%s 1
|
||||
static %s gen_%s(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
|
||||
return(NULL);
|
||||
}
|
||||
static void des_%s(int no ATTRIBUTE_UNUSED, %s val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
|
||||
}
|
||||
""" % (name, crtype, name, name, rtype))
|
||||
add_generated_param_type(name)
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
#
|
||||
@ -383,7 +417,7 @@ def generate_test(module, node):
|
||||
info = arg.xpathEval("string(@info)")
|
||||
nam = arg.xpathEval("string(@name)")
|
||||
type = type_convert(rtype, nam, info, module, name, n)
|
||||
if is_known_param_type(type) == 0:
|
||||
if is_known_param_type(type, rtype) == 0:
|
||||
add_missing_type(type, name);
|
||||
no_gen = 1
|
||||
t_args.append((nam, type, rtype, info))
|
||||
@ -442,8 +476,13 @@ test_%s(void) {
|
||||
# Declare the arguments
|
||||
for arg in t_args:
|
||||
(nam, type, rtype, info) = arg;
|
||||
if (type[-3:] == 'Ptr' or type[-4:] == '_ptr') and \
|
||||
rtype[0:6] == 'const ':
|
||||
crtype = rtype[6:]
|
||||
else:
|
||||
crtype = rtype
|
||||
# add declaration
|
||||
test.write(" %s %s; /* %s */\n" % (rtype, nam, info))
|
||||
test.write(" %s %s; /* %s */\n" % (crtype, nam, info))
|
||||
test.write(" int n_%s;\n" % (nam))
|
||||
test.write("\n")
|
||||
|
||||
|
2
parser.c
2
parser.c
@ -10384,6 +10384,8 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
|
||||
xmlChar start[4];
|
||||
xmlCharEncoding enc;
|
||||
|
||||
if (ctx == NULL) return(-1);
|
||||
|
||||
if (ctx->depth > 40) {
|
||||
return(XML_ERR_ENTITY_LOOP);
|
||||
}
|
||||
|
@ -281,6 +281,7 @@ xmlParserInputRead(xmlParserInputPtr in, int len) {
|
||||
int used;
|
||||
int indx;
|
||||
|
||||
if (in == NULL) return(-1);
|
||||
#ifdef DEBUG_INPUT
|
||||
xmlGenericError(xmlGenericErrorContext, "Read\n");
|
||||
#endif
|
||||
@ -330,6 +331,7 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
|
||||
int ret;
|
||||
int indx;
|
||||
|
||||
if (in == NULL) return(-1);
|
||||
#ifdef DEBUG_INPUT
|
||||
xmlGenericError(xmlGenericErrorContext, "Grow\n");
|
||||
#endif
|
||||
@ -1798,6 +1800,7 @@ xmlClearParserCtxt(xmlParserCtxtPtr ctxt)
|
||||
xmlCtxtReset(ctxt);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* xmlParserFindNodeInfo:
|
||||
* @ctx: an XML parser context
|
||||
@ -1807,17 +1810,20 @@ xmlClearParserCtxt(xmlParserCtxtPtr ctxt)
|
||||
*
|
||||
* Returns an xmlParserNodeInfo block pointer or NULL
|
||||
*/
|
||||
const xmlParserNodeInfo* xmlParserFindNodeInfo(const xmlParserCtxtPtr ctx,
|
||||
const xmlNodePtr node)
|
||||
const xmlParserNodeInfo *
|
||||
xmlParserFindNodeInfo(const xmlParserCtxtPtr ctx, const xmlNodePtr node)
|
||||
{
|
||||
unsigned long pos;
|
||||
unsigned long pos;
|
||||
|
||||
/* Find position where node should be at */
|
||||
pos = xmlParserFindNodeInfoIndex(&ctx->node_seq, node);
|
||||
if (pos < ctx->node_seq.length && ctx->node_seq.buffer[pos].node == node)
|
||||
return &ctx->node_seq.buffer[pos];
|
||||
else
|
||||
return NULL;
|
||||
if ((ctx == NULL) || (node == NULL))
|
||||
return (NULL);
|
||||
/* Find position where node should be at */
|
||||
pos = xmlParserFindNodeInfoIndex(&ctx->node_seq, node);
|
||||
if (pos < ctx->node_seq.length
|
||||
&& ctx->node_seq.buffer[pos].node == node)
|
||||
return &ctx->node_seq.buffer[pos];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -1830,9 +1836,11 @@ const xmlParserNodeInfo* xmlParserFindNodeInfo(const xmlParserCtxtPtr ctx,
|
||||
void
|
||||
xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)
|
||||
{
|
||||
seq->length = 0;
|
||||
seq->maximum = 0;
|
||||
seq->buffer = NULL;
|
||||
if (seq == NULL)
|
||||
return;
|
||||
seq->length = 0;
|
||||
seq->maximum = 0;
|
||||
seq->buffer = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1845,12 +1853,13 @@ xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)
|
||||
void
|
||||
xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)
|
||||
{
|
||||
if ( seq->buffer != NULL )
|
||||
xmlFree(seq->buffer);
|
||||
xmlInitNodeInfoSeq(seq);
|
||||
if (seq == NULL)
|
||||
return;
|
||||
if (seq->buffer != NULL)
|
||||
xmlFree(seq->buffer);
|
||||
xmlInitNodeInfoSeq(seq);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* xmlParserFindNodeInfoIndex:
|
||||
* @seq: a node info sequence pointer
|
||||
@ -1862,31 +1871,35 @@ xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)
|
||||
*
|
||||
* Returns a long indicating the position of the record
|
||||
*/
|
||||
unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
|
||||
const xmlNodePtr node)
|
||||
unsigned long
|
||||
xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
|
||||
const xmlNodePtr node)
|
||||
{
|
||||
unsigned long upper, lower, middle;
|
||||
int found = 0;
|
||||
unsigned long upper, lower, middle;
|
||||
int found = 0;
|
||||
|
||||
/* Do a binary search for the key */
|
||||
lower = 1;
|
||||
upper = seq->length;
|
||||
middle = 0;
|
||||
while ( lower <= upper && !found) {
|
||||
middle = lower + (upper - lower) / 2;
|
||||
if ( node == seq->buffer[middle - 1].node )
|
||||
found = 1;
|
||||
else if ( node < seq->buffer[middle - 1].node )
|
||||
upper = middle - 1;
|
||||
if ((seq == NULL) || (node == NULL))
|
||||
return (-1);
|
||||
|
||||
/* Do a binary search for the key */
|
||||
lower = 1;
|
||||
upper = seq->length;
|
||||
middle = 0;
|
||||
while (lower <= upper && !found) {
|
||||
middle = lower + (upper - lower) / 2;
|
||||
if (node == seq->buffer[middle - 1].node)
|
||||
found = 1;
|
||||
else if (node < seq->buffer[middle - 1].node)
|
||||
upper = middle - 1;
|
||||
else
|
||||
lower = middle + 1;
|
||||
}
|
||||
|
||||
/* Return position */
|
||||
if (middle == 0 || seq->buffer[middle - 1].node < node)
|
||||
return middle;
|
||||
else
|
||||
lower = middle + 1;
|
||||
}
|
||||
|
||||
/* Return position */
|
||||
if ( middle == 0 || seq->buffer[middle - 1].node < node )
|
||||
return middle;
|
||||
else
|
||||
return middle - 1;
|
||||
return middle - 1;
|
||||
}
|
||||
|
||||
|
||||
@ -1903,6 +1916,8 @@ xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
|
||||
{
|
||||
unsigned long pos;
|
||||
|
||||
if ((ctxt == NULL) || (info == NULL)) return;
|
||||
|
||||
/* Find pos and check to see if node is already in the sequence */
|
||||
pos = xmlParserFindNodeInfoIndex(&ctxt->node_seq, (xmlNodePtr)
|
||||
info->node);
|
||||
|
@ -7671,6 +7671,8 @@ xmlRelaxNGDumpGrammar(FILE * output, xmlRelaxNGGrammarPtr grammar, int top)
|
||||
void
|
||||
xmlRelaxNGDump(FILE * output, xmlRelaxNGPtr schema)
|
||||
{
|
||||
if (output == NULL)
|
||||
return;
|
||||
if (schema == NULL) {
|
||||
fprintf(output, "RelaxNG empty or failed to compile\n");
|
||||
return;
|
||||
@ -7700,6 +7702,8 @@ xmlRelaxNGDump(FILE * output, xmlRelaxNGPtr schema)
|
||||
void
|
||||
xmlRelaxNGDumpTree(FILE * output, xmlRelaxNGPtr schema)
|
||||
{
|
||||
if (output == NULL)
|
||||
return;
|
||||
if (schema == NULL) {
|
||||
fprintf(output, "RelaxNG empty or failed to compile\n");
|
||||
return;
|
||||
|
15
valid.c
15
valid.c
@ -1517,6 +1517,8 @@ xmlCopyElementTable(xmlElementTablePtr table) {
|
||||
*/
|
||||
void
|
||||
xmlDumpElementDecl(xmlBufferPtr buf, xmlElementPtr elem) {
|
||||
if ((buf == NULL) || (elem == NULL))
|
||||
return;
|
||||
switch (elem->etype) {
|
||||
case XML_ELEMENT_TYPE_EMPTY:
|
||||
xmlBufferWriteChar(buf, "<!ELEMENT ");
|
||||
@ -1587,6 +1589,8 @@ xmlDumpElementDeclScan(xmlElementPtr elem, xmlBufferPtr buf) {
|
||||
*/
|
||||
void
|
||||
xmlDumpElementTable(xmlBufferPtr buf, xmlElementTablePtr table) {
|
||||
if ((buf == NULL) || (table == NULL))
|
||||
return;
|
||||
xmlHashScan(table, (xmlHashScanner) xmlDumpElementDeclScan, buf);
|
||||
}
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
@ -1666,7 +1670,8 @@ xmlCopyEnumeration(xmlEnumerationPtr cur) {
|
||||
*/
|
||||
static void
|
||||
xmlDumpEnumeration(xmlBufferPtr buf, xmlEnumerationPtr cur) {
|
||||
if (cur == NULL) return;
|
||||
if ((buf == NULL) || (cur == NULL))
|
||||
return;
|
||||
|
||||
xmlBufferWriteCHAR(buf, cur->name);
|
||||
if (cur->next == NULL)
|
||||
@ -2073,6 +2078,8 @@ xmlCopyAttributeTable(xmlAttributeTablePtr table) {
|
||||
*/
|
||||
void
|
||||
xmlDumpAttributeDecl(xmlBufferPtr buf, xmlAttributePtr attr) {
|
||||
if ((buf == NULL) || (attr == NULL))
|
||||
return;
|
||||
xmlBufferWriteChar(buf, "<!ATTLIST ");
|
||||
xmlBufferWriteCHAR(buf, attr->elem);
|
||||
xmlBufferWriteChar(buf, " ");
|
||||
@ -2164,6 +2171,8 @@ xmlDumpAttributeDeclScan(xmlAttributePtr attr, xmlBufferPtr buf) {
|
||||
*/
|
||||
void
|
||||
xmlDumpAttributeTable(xmlBufferPtr buf, xmlAttributeTablePtr table) {
|
||||
if ((buf == NULL) || (table == NULL))
|
||||
return;
|
||||
xmlHashScan(table, (xmlHashScanner) xmlDumpAttributeDeclScan, buf);
|
||||
}
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
@ -2347,6 +2356,8 @@ xmlCopyNotationTable(xmlNotationTablePtr table) {
|
||||
*/
|
||||
void
|
||||
xmlDumpNotationDecl(xmlBufferPtr buf, xmlNotationPtr nota) {
|
||||
if ((buf == NULL) || (nota == NULL))
|
||||
return;
|
||||
xmlBufferWriteChar(buf, "<!NOTATION ");
|
||||
xmlBufferWriteCHAR(buf, nota->name);
|
||||
if (nota->PublicID != NULL) {
|
||||
@ -2384,6 +2395,8 @@ xmlDumpNotationDeclScan(xmlNotationPtr nota, xmlBufferPtr buf) {
|
||||
*/
|
||||
void
|
||||
xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table) {
|
||||
if ((buf == NULL) || (table == NULL))
|
||||
return;
|
||||
xmlHashScan(table, (xmlHashScanner) xmlDumpNotationDeclScan, buf);
|
||||
}
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
6
xmlIO.c
6
xmlIO.c
@ -773,11 +773,13 @@ xmlFileOpenW (const char *filename) {
|
||||
*
|
||||
* Read @len bytes to @buffer from the I/O channel.
|
||||
*
|
||||
* Returns the number of bytes written
|
||||
* Returns the number of bytes written or < 0 in case of failure
|
||||
*/
|
||||
int
|
||||
xmlFileRead (void * context, char * buffer, int len) {
|
||||
int ret;
|
||||
if ((context == NULL) || (buffer == NULL))
|
||||
return(-1);
|
||||
ret = fread(&buffer[0], 1, len, (FILE *) context);
|
||||
if (ret < 0) xmlIOErr(0, "fread()");
|
||||
return(ret);
|
||||
@ -798,6 +800,8 @@ static int
|
||||
xmlFileWrite (void * context, const char * buffer, int len) {
|
||||
int items;
|
||||
|
||||
if ((context == NULL) || (buffer == NULL))
|
||||
return(-1);
|
||||
items = fwrite(&buffer[0], len, 1, (FILE *) context);
|
||||
if ((items == 0) && (ferror((FILE *) context))) {
|
||||
xmlIOErr(0, "fwrite()");
|
||||
|
@ -3724,6 +3724,8 @@ xmlTextReaderCurrentDoc(xmlTextReaderPtr reader) {
|
||||
*/
|
||||
int
|
||||
xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, xmlRelaxNGPtr schema) {
|
||||
if (reader == NULL)
|
||||
return(-1);
|
||||
if (schema == NULL) {
|
||||
if (reader->rngSchemas != NULL) {
|
||||
xmlRelaxNGFree(reader->rngSchemas);
|
||||
@ -3963,6 +3965,8 @@ xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator) {
|
||||
xmlParserCtxtPtr ctx = (xmlParserCtxtPtr)locator;
|
||||
int ret = -1;
|
||||
|
||||
if (locator == NULL)
|
||||
return(-1);
|
||||
if (ctx->node != NULL) {
|
||||
ret = xmlGetLineNo(ctx->node);
|
||||
}
|
||||
@ -3997,6 +4001,8 @@ xmlTextReaderLocatorBaseURI(xmlTextReaderLocatorPtr locator) {
|
||||
xmlParserCtxtPtr ctx = (xmlParserCtxtPtr)locator;
|
||||
xmlChar *ret = NULL;
|
||||
|
||||
if (locator == NULL)
|
||||
return(NULL);
|
||||
if (ctx->node != NULL) {
|
||||
ret = xmlNodeGetBase(NULL,ctx->node);
|
||||
}
|
||||
|
@ -1436,6 +1436,7 @@ xmlSaveDoc(xmlSaveCtxtPtr ctxt, xmlDocPtr doc)
|
||||
{
|
||||
long ret = 0;
|
||||
|
||||
if ((ctxt == NULL) || (doc == NULL)) return(-1);
|
||||
xmlDocContentDumpOutput(ctxt, doc);
|
||||
return(ret);
|
||||
}
|
||||
@ -1456,6 +1457,7 @@ xmlSaveTree(xmlSaveCtxtPtr ctxt, xmlNodePtr node)
|
||||
{
|
||||
long ret = 0;
|
||||
|
||||
if ((ctxt == NULL) || (node == NULL)) return(-1);
|
||||
xmlNodeDumpOutputInternal(ctxt, node);
|
||||
return(ret);
|
||||
}
|
||||
|
@ -2434,6 +2434,8 @@ xmlSchemaTypeDump(xmlSchemaTypePtr type, FILE * output)
|
||||
void
|
||||
xmlSchemaDump(FILE * output, xmlSchemaPtr schema)
|
||||
{
|
||||
if (output == NULL)
|
||||
return;
|
||||
if (schema == NULL) {
|
||||
fprintf(output, "Schemas: NULL\n");
|
||||
return;
|
||||
@ -12574,6 +12576,8 @@ xmlSchemaCheckFacet(xmlSchemaFacetPtr facet,
|
||||
xmlSchemaTypePtr nonNegativeIntegerType = NULL;
|
||||
int ret = 0, reuseValCtxt = 0;
|
||||
|
||||
if ((facet == NULL) || (typeDecl == NULL))
|
||||
return(-1);
|
||||
/*
|
||||
* TODO: will the parser context be given if used from
|
||||
* the relaxNG module?
|
||||
|
@ -470,6 +470,8 @@ xmlSchemaCleanupTypes(void) {
|
||||
int
|
||||
xmlSchemaIsBuiltInTypeFacet(xmlSchemaTypePtr type, int facetType)
|
||||
{
|
||||
if (type == NULL)
|
||||
return (-1);
|
||||
if (type->type != XML_SCHEMA_TYPE_BASIC)
|
||||
return (-1);
|
||||
switch (type->builtInType) {
|
||||
@ -3789,6 +3791,8 @@ xmlSchemaValidateListSimpleTypeFacet(xmlSchemaFacetPtr facet,
|
||||
unsigned long actualLen,
|
||||
unsigned long *expectedLen)
|
||||
{
|
||||
if (facet == NULL)
|
||||
return(-1);
|
||||
/*
|
||||
* TODO: Check if this will work with large numbers.
|
||||
* (compare value.decimal.mi and value.decimal.hi as well?).
|
||||
@ -3844,6 +3848,8 @@ xmlSchemaValidateLengthFacet(xmlSchemaTypePtr type,
|
||||
{
|
||||
unsigned int len = 0;
|
||||
|
||||
if ((length == NULL) || (facet == NULL) || (type == NULL))
|
||||
return (-1);
|
||||
*length = 0;
|
||||
if ((facet->type != XML_SCHEMA_FACET_LENGTH) &&
|
||||
(facet->type != XML_SCHEMA_FACET_MAXLENGTH) &&
|
||||
@ -3918,6 +3924,8 @@ xmlSchemaValidateFacet(xmlSchemaTypePtr base ATTRIBUTE_UNUSED,
|
||||
{
|
||||
int ret;
|
||||
|
||||
if ((facet == NULL) || (value == NULL))
|
||||
return(-1);
|
||||
switch (facet->type) {
|
||||
case XML_SCHEMA_FACET_PATTERN:
|
||||
ret = xmlRegexpExec(facet->regexp, value);
|
||||
|
@ -745,7 +745,8 @@ xmlGetUTF8Char(const unsigned char *utf, int *len) {
|
||||
return(c);
|
||||
|
||||
error:
|
||||
*len = 0;
|
||||
if (len != NULL)
|
||||
*len = 0;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@ -768,6 +769,8 @@ xmlCheckUTF8(const unsigned char *utf)
|
||||
int ix;
|
||||
unsigned char c;
|
||||
|
||||
if (utf == NULL)
|
||||
return(0);
|
||||
/*
|
||||
* utf is a string of 1, 2, 3 or 4 bytes. The valid strings
|
||||
* are as follows (in "bit format"):
|
||||
|
7
xpath.c
7
xpath.c
@ -3932,16 +3932,19 @@ xmlXPathFreeContext(xmlXPathContextPtr ctxt) {
|
||||
xmlGenericError(xmlGenericErrorContext, \
|
||||
"%s:%d Internal error: no context\n", \
|
||||
__FILE__, __LINE__); \
|
||||
return(NULL); \
|
||||
} \
|
||||
else if (ctxt->doc == NULL) { \
|
||||
xmlGenericError(xmlGenericErrorContext, \
|
||||
"%s:%d Internal error: no document\n", \
|
||||
__FILE__, __LINE__); \
|
||||
return(NULL); \
|
||||
} \
|
||||
else if (ctxt->doc->children == NULL) { \
|
||||
xmlGenericError(xmlGenericErrorContext, \
|
||||
"%s:%d Internal error: document without root\n", \
|
||||
__FILE__, __LINE__); \
|
||||
return(NULL); \
|
||||
} \
|
||||
|
||||
|
||||
@ -10915,7 +10918,7 @@ xmlXPathRunEval(xmlXPathParserContextPtr ctxt) {
|
||||
*/
|
||||
int
|
||||
xmlXPathEvalPredicate(xmlXPathContextPtr ctxt, xmlXPathObjectPtr res) {
|
||||
if (res == NULL) return(0);
|
||||
if ((ctxt == NULL) || (res == NULL)) return(0);
|
||||
switch (res->type) {
|
||||
case XPATH_BOOLEAN:
|
||||
return(res->boolval);
|
||||
@ -10954,7 +10957,7 @@ xmlXPathEvalPredicate(xmlXPathContextPtr ctxt, xmlXPathObjectPtr res) {
|
||||
int
|
||||
xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
|
||||
xmlXPathObjectPtr res) {
|
||||
if (res == NULL) return(0);
|
||||
if ((ctxt == NULL) || (res == NULL)) return(0);
|
||||
switch (res->type) {
|
||||
case XPATH_BOOLEAN:
|
||||
return(res->boolval);
|
||||
|
@ -642,7 +642,7 @@ void
|
||||
xmlXPtrLocationSetAdd(xmlLocationSetPtr cur, xmlXPathObjectPtr val) {
|
||||
int i;
|
||||
|
||||
if (val == NULL) return;
|
||||
if ((cur == NULL) || (val == NULL)) return;
|
||||
|
||||
/*
|
||||
* check against doublons
|
||||
@ -2227,6 +2227,7 @@ xmlXPtrRangeToFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
||||
xmlNodeSetPtr oldset;
|
||||
int i;
|
||||
|
||||
if (ctxt == NULL) return;
|
||||
CHECK_ARITY(1);
|
||||
/*
|
||||
* Save the expression pointer since we will have to evaluate
|
||||
@ -2904,6 +2905,8 @@ xmlXPtrEvalRangePredicate(xmlXPathParserContextPtr ctxt) {
|
||||
xmlLocationSetPtr oldset;
|
||||
int i;
|
||||
|
||||
if (ctxt == NULL) return;
|
||||
|
||||
SKIP_BLANKS;
|
||||
if (CUR != '[') {
|
||||
XP_ERROR(XPATH_INVALID_PREDICATE_ERROR);
|
||||
|
Loading…
Reference in New Issue
Block a user