mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
string_decoder: throw an error when writing a too long buffer
PR-URL: https://github.com/nodejs/node/pull/52215 Fixes: https://github.com/nodejs/node/issues/52214 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: theanarkh <theratliter@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
8b2011a818
commit
8123be16a5
2 files changed
+34
-5
No files matched your search
@@ -31,11 +31,11 @@ MaybeLocal<String> MakeString(Isolate* isolate,
|
||||
Local<Value> error;
|
||||
MaybeLocal<Value> ret;
|
||||
if (encoding == UTF8) {
|
||||
MaybeLocal<String> utf8_string = String::NewFromUtf8(
|
||||
isolate,
|
||||
data,
|
||||
v8::NewStringType::kNormal,
|
||||
length);
|
||||
MaybeLocal<String> utf8_string;
|
||||
if (length <= static_cast<size_t>(v8::String::kMaxLength)) {
|
||||
utf8_string = String::NewFromUtf8(
|
||||
isolate, data, v8::NewStringType::kNormal, length);
|
||||
}
|
||||
if (utf8_string.IsEmpty()) {
|
||||
isolate->ThrowException(node::ERR_STRING_TOO_LONG(isolate));
|
||||
return MaybeLocal<String>();
|
||||
|
||||
Reference in new issue
Block a user