From: Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Date: Thu, 9 Aug 2001 18:08:56 +0000 (+0000)
Subject: XML_Parse():  If XML_GetBuffer() returns NULL, do not attempt to move
X-Git-Tag: R_1_95_3~142
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=57a3480f956b5187485a55d36300d19efa04b07f;p=libexpat

XML_Parse():  If XML_GetBuffer() returns NULL, do not attempt to move
    data aronud, just propogate the error.

This closes SF bug #434665.
---

diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c
index 7c6a8017..df69b749 100644
--- a/expat/lib/xmlparse.c
+++ b/expat/lib/xmlparse.c
@@ -1134,8 +1134,13 @@ int XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
   }
 #endif  /* not defined XML_CONTEXT_BYTES */
   else {
-    memcpy(XML_GetBuffer(parser, len), s, len);
-    return XML_ParseBuffer(parser, len, isFinal);
+    void *buff = XML_GetBuffer(parser, len);
+    if (buff == NULL)
+      return 0;
+    else {
+      memcpy(buff, s, len);
+      return XML_ParseBuffer(parser, len, isFinal);
+    }
   }
 }