mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
Add test cases for bug 758518
test/HTML/758518-entity.html exposed a bug in pushParseTest() in runtest.c which assumed that an input file was at least 4 bytes long. That test case is only 3 bytes, so we now take the minimum of 4 bytes or the length of the test input. We also now use 'chunkSize' in place of the hard-coded value '1024' later in the function.
This commit is contained in:
committed by
Nick Wellnhofer
parent
ed48d65b4d
commit
85c112a082
19
runtest.c
19
runtest.c
@@ -1854,6 +1854,7 @@ pushParseTest(const char *filename, const char *result,
|
||||
const char *base;
|
||||
int size, res;
|
||||
int cur = 0;
|
||||
int chunkSize = 4;
|
||||
|
||||
nb_tests++;
|
||||
/*
|
||||
@@ -1864,17 +1865,21 @@ pushParseTest(const char *filename, const char *result,
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (chunkSize > size)
|
||||
chunkSize = size;
|
||||
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
if (options & XML_PARSE_HTML)
|
||||
ctxt = htmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename,
|
||||
ctxt = htmlCreatePushParserCtxt(NULL, NULL, base + cur, chunkSize, filename,
|
||||
XML_CHAR_ENCODING_NONE);
|
||||
else
|
||||
#endif
|
||||
ctxt = xmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename);
|
||||
ctxt = xmlCreatePushParserCtxt(NULL, NULL, base + cur, chunkSize, filename);
|
||||
xmlCtxtUseOptions(ctxt, options);
|
||||
cur += 4;
|
||||
cur += chunkSize;
|
||||
chunkSize = 1024;
|
||||
do {
|
||||
if (cur + 1024 >= size) {
|
||||
if (cur + chunkSize >= size) {
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
if (options & XML_PARSE_HTML)
|
||||
htmlParseChunk(ctxt, base + cur, size - cur, 1);
|
||||
@@ -1885,11 +1890,11 @@ pushParseTest(const char *filename, const char *result,
|
||||
} else {
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
if (options & XML_PARSE_HTML)
|
||||
htmlParseChunk(ctxt, base + cur, 1024, 0);
|
||||
htmlParseChunk(ctxt, base + cur, chunkSize, 0);
|
||||
else
|
||||
#endif
|
||||
xmlParseChunk(ctxt, base + cur, 1024, 0);
|
||||
cur += 1024;
|
||||
xmlParseChunk(ctxt, base + cur, chunkSize, 0);
|
||||
cur += chunkSize;
|
||||
}
|
||||
} while (cur < size);
|
||||
doc = ctxt->myDoc;
|
||||
|
||||
Reference in New Issue
Block a user