GeezerVison is showing github.com — crypto: simplify Hmac::HmacUpdate · nodejs/node@916a1d5
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node_crypto.cc +5-6Lines changed: 5 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3237,15 +3237,14 @@ void Hmac::HmacUpdate(const FunctionCallbackInfo<Value>& args) { |
3237 | 3237 | ASSIGN_OR_RETURN_UNWRAP(&hmac, args.Holder()); |
3238 | 3238 |
|
3239 | 3239 | // Only copy the data if we have to, because it's a string |
3240 | | - bool r = true; |
| 3240 | + bool r = false; |
3241 | 3241 | if (args[0]->IsString()) { |
3242 | 3242 | StringBytes::InlineDecoder decoder; |
3243 | | - if (!decoder.Decode(env, args[0].As<String>(), args[1], UTF8)) { |
3244 | | - args.GetReturnValue().Set(false); |
3245 | | - return; |
| 3243 | + if (decoder.Decode(env, args[0].As<String>(), args[1], UTF8)) { |
| 3244 | + r = hmac->HmacUpdate(decoder.out(), decoder.size()); |
3246 | 3245 | } |
3247 | | - r = hmac->HmacUpdate(decoder.out(), decoder.size()); |
3248 | | - } else if (args[0]->IsArrayBufferView()) { |
| 3246 | + } else { |
| 3247 | + CHECK(args[0]->IsArrayBufferView()); |
3249 | 3248 | char* buf = Buffer::Data(args[0]); |
3250 | 3249 | size_t buflen = Buffer::Length(args[0]); |
3251 | 3250 | r = hmac->HmacUpdate(buf, buflen); |
|