|
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"
|
@@ -617,8 +618,13 @@ void EnvGetter(Local<Name> property,
|
617 | 618 | if ((result > 0 || GetLastError() == ERROR_SUCCESS) &&
|
618 | 619 | result < arraysize(buffer)) {
|
619 | 620 | const uint16_t* two_byte_buffer = reinterpret_cast<const uint16_t*>(buffer);
|
620 |
| - Local<String> rc = String::NewFromTwoByte(isolate, two_byte_buffer); |
621 |
| - return info.GetReturnValue().Set(rc); |
| 621 | + v8::MaybeLocal<String> rc = String::NewFromTwoByte( |
| 622 | + isolate, two_byte_buffer, v8::NewStringType::kNormal); |
| 623 | + if (rc.IsEmpty()) { |
| 624 | + isolate->ThrowException(ERR_STRING_TOO_LONG(isolate)); |
| 625 | + return; |
| 626 | + } |
| 627 | + return info.GetReturnValue().Set(rc.ToLocalChecked()); |
622 | 628 | }
|
623 | 629 | #endif
|
624 | 630 | }
|
@@ -759,10 +765,17 @@ void EnvEnumerator(const PropertyCallbackInfo<Array>& info) {
|
759 | 765 | }
|
760 | 766 | const uint16_t* two_byte_buffer = reinterpret_cast<const uint16_t*>(p);
|
761 | 767 | const size_t two_byte_buffer_len = s - p;
|
762 |
| - argv[idx] = String::NewFromTwoByte(isolate, |
763 |
| - two_byte_buffer, |
764 |
| - String::kNormalString, |
765 |
| - two_byte_buffer_len); |
| 768 | + v8::MaybeLocal<String> rc = |
| 769 | + String::NewFromTwoByte(isolate, |
| 770 | + two_byte_buffer, |
| 771 | + v8::NewStringType::kNormal, |
| 772 | + two_byte_buffer_len); |
| 773 | + if (rc.IsEmpty()) { |
| 774 | + isolate->ThrowException(ERR_STRING_TOO_LONG(isolate)); |
| 775 | + FreeEnvironmentStringsW(environment); |
| 776 | + return; |
| 777 | + } |
| 778 | + argv[idx] = rc.ToLocalChecked(); |
766 | 779 | if (++idx >= arraysize(argv)) {
|
767 | 780 | fn->Call(ctx, envarr, idx, argv).ToLocalChecked();
|
768 | 781 | idx = 0;
|
|
0 commit comments