@@ -718,16 +718,16 @@ void StringWrite(const FunctionCallbackInfo<Value>& args) {
|
718 | 718 | size_t max_length; |
719 | 719 | |
720 | 720 | CHECK_NOT_OOB(ParseArrayIndex(args[1], 0, &offset)); |
| 721 | +if (offset >= ts_obj_length) |
| 722 | +return env->ThrowRangeError("Offset is out of bounds"); |
| 723 | + |
721 | 724 | CHECK_NOT_OOB(ParseArrayIndex(args[2], ts_obj_length - offset, &max_length)); |
722 | 725 | |
723 | 726 | max_length = MIN(ts_obj_length - offset, max_length); |
724 | 727 | |
725 | 728 | if (max_length == 0) |
726 | 729 | return args.GetReturnValue().Set(0); |
727 | 730 | |
728 | | -if (offset >= ts_obj_length) |
729 | | -return env->ThrowRangeError("Offset is out of bounds"); |
730 | | - |
731 | 731 | uint32_t written = StringBytes::Write(env->isolate(), |
732 | 732 | ts_obj_data + offset, |
733 | 733 | max_length, |
|