From 92cf2a317928cbfc7478005c2af46884b83d6daf Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Mon, 15 May 2017 18:50:53 +0100 Subject: [PATCH] Remove unreachable error code in character ref handling --- expat/lib/xmlparse.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c index ec3f885a..77ada82f 100644 --- a/expat/lib/xmlparse.c +++ b/expat/lib/xmlparse.c @@ -5788,12 +5788,15 @@ storeEntityValue(XML_Parser parser, goto endEntityValue; } n = XmlEncode(n, (ICHAR *)buf); - if (!n) { - if (enc == encoding) - eventPtr = entityTextPtr; - result = XML_ERROR_BAD_CHAR_REF; - goto endEntityValue; - } + /* The XmlEncode() functions can never return 0 here. That + * error return happens if the code point passed in is either + * negative or greater than or equal to 0x110000. The + * XmlCharRefNumber() functions will all return a number + * strictly less than 0x110000 or a negative value if an error + * occurred. The negative value is intercepted above, so + * XmlEncode() is never passed a value it might return an + * error for. + */ for (i = 0; i < n; i++) { if (pool->end == pool->ptr && !poolGrow(pool)) { result = XML_ERROR_NO_MEMORY; -- 2.40.0