mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
src: improve error handling in string_bytes/decoder
PR-URL: https://github.com/nodejs/node/pull/56978 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
1 parent
888e5eb4fd
commit
cbedcd1696
2 files changed
+25
-25
No files matched your search
@@ -272,19 +272,21 @@ void DecodeData(const FunctionCallbackInfo<Value>& args) {
|
||||
ArrayBufferViewContents<char> content(args[1].As<ArrayBufferView>());
|
||||
size_t length = content.length();
|
||||
|
||||
MaybeLocal<String> ret =
|
||||
decoder->DecodeData(args.GetIsolate(), content.data(), &length);
|
||||
if (!ret.IsEmpty())
|
||||
args.GetReturnValue().Set(ret.ToLocalChecked());
|
||||
Local<String> ret;
|
||||
if (decoder->DecodeData(args.GetIsolate(), content.data(), &length)
|
||||
.ToLocal(&ret)) {
|
||||
args.GetReturnValue().Set(ret);
|
||||
}
|
||||
}
|
||||
|
||||
void FlushData(const FunctionCallbackInfo<Value>& args) {
|
||||
StringDecoder* decoder =
|
||||
reinterpret_cast<StringDecoder*>(Buffer::Data(args[0]));
|
||||
CHECK_NOT_NULL(decoder);
|
||||
MaybeLocal<String> ret = decoder->FlushData(args.GetIsolate());
|
||||
if (!ret.IsEmpty())
|
||||
args.GetReturnValue().Set(ret.ToLocalChecked());
|
||||
Local<String> ret;
|
||||
if (decoder->FlushData(args.GetIsolate()).ToLocal(&ret)) {
|
||||
args.GetReturnValue().Set(ret);
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeStringDecoder(Local<Object> target,
|
||||
|
||||
Reference in new issue
Block a user