From d6072766ed7650c4f2a60c988df696d8fd41db8e Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 14 Jun 2010 14:38:40 -0700 Subject: [PATCH] Fix memory leak in hash.update() --- src/node_crypto.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 58c1c04489..2927a2664f 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -2048,12 +2048,11 @@ class Hash : public ObjectWrap { return args.This(); } - static Handle - HashUpdate(const Arguments& args) { - Hash *hash = ObjectWrap::Unwrap(args.This()); - + static Handle HashUpdate(const Arguments& args) { HandleScope scope; + Hash *hash = ObjectWrap::Unwrap(args.This()); + enum encoding enc = ParseEncoding(args[1]); ssize_t len = DecodeBytes(args[0], enc); @@ -2068,6 +2067,8 @@ class Hash : public ObjectWrap { int r = hash->HashUpdate(buf, len); + delete[] buf; + return args.This(); }