|
1 | 1 | #include "node.h"
|
2 | 2 | #include "node_internals.h"
|
| 3 | +#include "node_errors.h" |
3 | 4 | #include "base_object.h"
|
4 | 5 | #include "base_object-inl.h"
|
5 | 6 | #include "env-inl.h"
|
@@ -626,8 +627,13 @@ void EnvGetter(Local<Name> property,
|
626 | 627 | if ((result > 0 || GetLastError() == ERROR_SUCCESS) &&
|
627 | 628 | result < arraysize(buffer)) {
|
628 | 629 | const uint16_t* two_byte_buffer = reinterpret_cast<const uint16_t*>(buffer);
|
629 |
| - Local<String> rc = String::NewFromTwoByte(isolate, two_byte_buffer); |
630 |
| - return info.GetReturnValue().Set(rc); |
| 630 | + v8::MaybeLocal<String> rc = String::NewFromTwoByte( |
| 631 | + isolate, two_byte_buffer, v8::NewStringType::kNormal); |
| 632 | + if (rc.IsEmpty()) { |
| 633 | + isolate->ThrowException(ERR_STRING_TOO_LONG(isolate)); |
| 634 | + return; |
| 635 | + } |
| 636 | + return info.GetReturnValue().Set(rc.ToLocalChecked()); |
631 | 637 | }
|
632 | 638 | #endif
|
633 | 639 | }
|
@@ -768,10 +774,17 @@ void EnvEnumerator(const PropertyCallbackInfo<Array>& info) {
|
768 | 774 | }
|
769 | 775 | const uint16_t* two_byte_buffer = reinterpret_cast<const uint16_t*>(p);
|
770 | 776 | const size_t two_byte_buffer_len = s - p;
|
771 |
| - argv[idx] = String::NewFromTwoByte(isolate, |
772 |
| - two_byte_buffer, |
773 |
| - String::kNormalString, |
774 |
| - two_byte_buffer_len); |
| 777 | + v8::MaybeLocal<String> rc = |
| 778 | + String::NewFromTwoByte(isolate, |
| 779 | + two_byte_buffer, |
| 780 | + v8::NewStringType::kNormal, |
| 781 | + two_byte_buffer_len); |
| 782 | + if (rc.IsEmpty()) { |
| 783 | + isolate->ThrowException(ERR_STRING_TOO_LONG(isolate)); |
| 784 | + FreeEnvironmentStringsW(environment); |
| 785 | + return; |
| 786 | + } |
| 787 | + argv[idx] = rc.ToLocalChecked(); |
775 | 788 | if (++idx >= arraysize(argv)) {
|
776 | 789 | fn->Call(ctx, envarr, idx, argv).ToLocalChecked();
|
777 | 790 | idx = 0;
|
|
0 commit comments