[Pkg-javascript-commits] [node-expat] 27/371: parse(): check buffer param and raise TypeError
Jonas Smedegaard
dr at jones.dk
Sun Feb 28 09:59:41 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 ada063b66bd7866b83214ad210a1f2f58c8a732d
Author: Astro <astro at spaceboyz.net>
Date: Sun May 30 22:22:37 2010 +0200
parse(): check buffer param and raise TypeError
---
expat.cc | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/expat.cc b/expat.cc
index 231d8d9..fd1c098 100644
--- a/expat.cc
+++ b/expat.cc
@@ -98,12 +98,21 @@ protected:
}
else if (args.Length() >= 1 && args[0]->IsObject())
{
- /* TODO: is it really a buffer? */
- Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args[0]->ToObject());
- return scope.Close(parser->parseBuffer(*buffer, isFinal) ? True() : False());
+ Local<Object> obj = args[0]->ToObject();
+ if (Buffer::HasInstance(obj))
+ {
+ Buffer *buffer = ObjectWrap::Unwrap<Buffer>(obj);
+ return scope.Close(parser->parseBuffer(*buffer, isFinal) ? True() : False());
+ }
+ else
+ return ThrowException(
+ Exception::TypeError(
+ String::New("Parse buffer must be String or Buffer")));
}
else
- return scope.Close(False());
+ return ThrowException(
+ Exception::TypeError(
+ String::New("Parse buffer must be String or Buffer")));
}
/** Parse a v8 String by first writing it to the expat parser's
--
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