diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 3970a2a514f..639e99d0e26 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1719,19 +1719,19 @@ class Decipher : public ObjectWrap { if (alloc_buf) { delete [] buf; - alloc_buf = false; } buf = ciphertext; len = ciphertext_len; + alloc_buf = true; } else if (strcasecmp(*encoding, "base64") == 0) { unbase64((unsigned char*)buf, len, (char **)&ciphertext, &ciphertext_len); if (alloc_buf) { delete [] buf; - alloc_buf = false; } buf = ciphertext; len = ciphertext_len; + alloc_buf = true; } else if (strcasecmp(*encoding, "binary") == 0) { // Binary - do nothing