From 9a26946aaa99a3f27905d5ba91220784e864e5d0 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 19 Jul 2010 10:32:56 -0700 Subject: [PATCH] Fix for issue #214 --- src/node_crypto.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index c16f660698..de335483d1 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1783,13 +1783,17 @@ class Hash : public ObjectWrap { return ThrowException(exception); } - char* buf = new char[len]; - ssize_t written = DecodeWrite(buf, len, args[0], enc); - assert(written == len); - int r = hash->HashUpdate(buf, len); - - delete[] buf; + if (Buffer::HasInstance(args[0])) { + Buffer *buffer = ObjectWrap::Unwrap(args[0]->ToObject()); + int r = hash->HashUpdate(buffer->data(), buffer->length()); + } else { + char* buf = new char[len]; + ssize_t written = DecodeWrite(buf, len, args[0], enc); + assert(written == len); + int r = hash->HashUpdate(buf, len); + delete[] buf; + } return args.This(); }