diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 1237157da3f775..f9c7d83605ea15 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -3252,15 +3252,14 @@ void Hmac::HmacUpdate(const FunctionCallbackInfo& args) { ASSIGN_OR_RETURN_UNWRAP(&hmac, args.Holder()); // Only copy the data if we have to, because it's a string - bool r = true; + bool r = false; if (args[0]->IsString()) { StringBytes::InlineDecoder decoder; - if (!decoder.Decode(env, args[0].As(), args[1], UTF8)) { - args.GetReturnValue().Set(false); - return; + if (decoder.Decode(env, args[0].As(), args[1], UTF8)) { + r = hmac->HmacUpdate(decoder.out(), decoder.size()); } - r = hmac->HmacUpdate(decoder.out(), decoder.size()); - } else if (args[0]->IsArrayBufferView()) { + } else { + CHECK(args[0]->IsArrayBufferView()); char* buf = Buffer::Data(args[0]); size_t buflen = Buffer::Length(args[0]); r = hmac->HmacUpdate(buf, buflen);