crypto: avoid memory leak
authorBrian White <mscdex@mscdex.net>
Tue, 2 Sep 2014 13:26:14 +0000 (09:26 -0400)
committerFedor Indutny <fedor@indutny.com>
Tue, 2 Sep 2014 13:41:21 +0000 (17:41 +0400)
Reviewed-By: Fedor Indutny <fedor@indutny.com>
src/node_crypto.cc

index a922be6..329ca9c 100644 (file)
@@ -4506,13 +4506,14 @@ void PBKDF2(const FunctionCallbackInfo<Value>& args) {
     goto err;
   }
 
+  ASSERT_IS_BUFFER(args[1]);
+
   pass = static_cast<char*>(malloc(passlen));
   if (pass == NULL) {
     FatalError("node::PBKDF2()", "Out of Memory");
   }
   memcpy(pass, Buffer::Data(args[0]), passlen);
 
-  ASSERT_IS_BUFFER(args[1]);
   saltlen = Buffer::Length(args[1]);
   if (saltlen < 0) {
     type_error = "Bad salt";