[Pkg-javascript-commits] [node-expat] 76/371: don't assert anything when parsing empty buffer

Jonas Smedegaard dr at jones.dk
Sun Feb 28 09:59:47 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository node-expat.

commit 92c3bdde9563d5dc6b065de015668e217ccb36cb
Author: Astro <astro at spaceboyz.net>
Date:   Tue Jun 14 02:21:37 2011 +0200

    don't assert anything when parsing empty buffer
---
 node-expat.cc | 3 +++
 test.js       | 7 +++++++
 2 files changed, 10 insertions(+)

diff --git a/node-expat.cc b/node-expat.cc
index 50150cd..05d87db 100644
--- a/node-expat.cc
+++ b/node-expat.cc
@@ -134,6 +134,9 @@ protected:
   bool parseString(String &str, int isFinal)
   {
     int len = str.Utf8Length();
+    if (len == 0)
+      return true;
+
     void *buf = XML_GetBuffer(parser, len);
     assert(buf != NULL);
     assert(str.WriteUtf8(static_cast<char *>(buf), len) == len);
diff --git a/test.js b/test.js
index 00b70dc..ad83b4d 100644
--- a/test.js
+++ b/test.js
@@ -229,5 +229,12 @@ vows.describe('node-expat').addBatch({
 
 	    assert.ok(p.parse(input));
 	}
+    },
+    'corner cases': {
+	'parse empty string': function() {
+	    var p = new expat.Parser("UTF-8");
+	    p.parse('');
+	    assert.ok(true, "Did not segfault");
+	}
     }
 }).run();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-expat.git



More information about the Pkg-javascript-commits mailing list