diff options
Diffstat (limited to 'expat/lib/xmlparse.c')
-rw-r--r-- | expat/lib/xmlparse.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c index 5825b1f1..ba506a33 100644 --- a/expat/lib/xmlparse.c +++ b/expat/lib/xmlparse.c @@ -536,6 +536,7 @@ static XML_Char *poolAppend(STRING_POOL *pool, const ENCODING *enc, static XML_Char *poolStoreString(STRING_POOL *pool, const ENCODING *enc, const char *ptr, const char *end); static XML_Bool FASTCALL poolGrow(STRING_POOL *pool); +static XML_Bool FASTCALL poolGrowUntil(STRING_POOL *pool, size_t needed); static const XML_Char *FASTCALL poolCopyString(STRING_POOL *pool, const XML_Char *s); static const XML_Char *poolCopyStringN(STRING_POOL *pool, const XML_Char *s, @@ -599,6 +600,11 @@ static unsigned long getDebugLevel(const char *variableName, (((pool)->ptr == (pool)->end && ! poolGrow(pool)) \ ? 0 \ : ((*((pool)->ptr)++ = c), 1)) +#define poolAppendChars(pool, s, len) \ + (! poolGrowUntil((pool), (len)) \ + ? 0 \ + : (memcpy((pool)->ptr, (s), (len) * sizeof(XML_Char)), \ + (pool)->ptr += (len), 1)) struct XML_ParserStruct { /* The first member must be m_userData so that the XML_GetUserData @@ -7268,6 +7274,19 @@ poolGrow(STRING_POOL *pool) { return XML_TRUE; } +static XML_Bool FASTCALL +poolGrowUntil(STRING_POOL *pool, size_t needed) { + for (;;) { + const size_t available = pool->end - pool->ptr; + if (available >= needed) { + return XML_TRUE; + } + if (! poolGrow(pool)) { + return XML_FALSE; + } + } +} + static int FASTCALL nextScaffoldPart(XML_Parser parser) { DTD *const dtd = parser->m_dtd; /* save one level of indirection */ |