src: don't call DecodeWrite() on Buffers
authorBen Noordhuis <info@bnoordhuis.nl>
Sat, 15 Mar 2014 01:04:02 +0000 (02:04 +0100)
committerFedor Indutny <fedor.indutny@gmail.com>
Sun, 16 Mar 2014 12:15:34 +0000 (16:15 +0400)
commitc30cc4e3a5ead3ca5b48e8eec445740775888ed8
treeaf71c08d61697753c053098f0bd5c8727c0f419e
parente87ceb2b427a9b51a55af5898c2ef24b4cc08af2
src: don't call DecodeWrite() on Buffers

Don't call DecodeWrite() with a Buffer as its argument because it in
turn calls StringBytes::Write() and that method expects a Local<String>.

"Why then does that function take a Local<Value>?" I hear you ask.
Good question but I don't have the answer.  I added a CHECK for good
measure and what do you know, all of a sudden a large number of crypto
tests started failing.

Calling DecodeWrite(BINARY) on a buffer is nonsensical anyway: if you
want the contents of the buffer, just copy out the data, there is no
need to decode it - and that's exactly what this commit does.

Fixes a great many instances of the following run-time error in debug
builds:

    FATAL ERROR: v8::String::Cast() Could not convert to string
src/node_crypto.cc
src/string_bytes.cc