From 758e83d100203f1e0243f7bd5594c2f652407cd3 Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Mon, 15 May 2017 18:42:18 +0100 Subject: [PATCH] Remove unreachable error handling code in character ref handling --- expat/lib/xmlparse.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c index 5713252f..73c7d39f 100644 --- a/expat/lib/xmlparse.c +++ b/expat/lib/xmlparse.c @@ -5513,11 +5513,15 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) break; n = XmlEncode(n, (ICHAR *)buf); - if (!n) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_BAD_CHAR_REF; - } + /* 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 (!poolAppendChar(pool, buf[i])) return XML_ERROR_NO_MEMORY; -- 2.40.0