File tree 1 file changed +13
-11
lines changed
1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -653,11 +653,11 @@ MaybeLocal<Value> StringBytes::Encode(Isolate* isolate,
653
653
return MaybeLocal<Value>();
654
654
}
655
655
auto maybe_buf = Buffer::Copy (isolate, buf, buflen);
656
- if (maybe_buf.IsEmpty ()) {
656
+ Local<v8::Object> buf;
657
+ if (!maybe_buf.ToLocal (&buf)) {
657
658
*error = node::ERR_MEMORY_ALLOCATION_FAILED (isolate);
658
- return MaybeLocal<Value>();
659
659
}
660
- return maybe_buf. ToLocalChecked () ;
660
+ return buf ;
661
661
}
662
662
663
663
case ASCII:
@@ -674,15 +674,17 @@ MaybeLocal<Value> StringBytes::Encode(Isolate* isolate,
674
674
}
675
675
676
676
case UTF8:
677
- val = String::NewFromUtf8 (isolate,
678
- buf,
679
- v8::NewStringType::kNormal ,
680
- buflen);
681
- if (val.IsEmpty ()) {
682
- *error = node::ERR_STRING_TOO_LONG (isolate);
683
- return MaybeLocal<Value>();
677
+ {
678
+ val = String::NewFromUtf8 (isolate,
679
+ buf,
680
+ v8::NewStringType::kNormal ,
681
+ buflen);
682
+ Local<String> str;
683
+ if (!val.ToLocal (&str)) {
684
+ *error = node::ERR_STRING_TOO_LONG (isolate);
685
+ }
686
+ return str;
684
687
}
685
- return val.ToLocalChecked ();
686
688
687
689
case LATIN1:
688
690
return ExternOneByteString::NewFromCopy (isolate, buf, buflen, error);
You can’t perform that action at this time.
0 commit comments