summaryrefslogtreecommitdiff
path: root/src/node_file.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/node_file.cc')
-rw-r--r--src/node_file.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/node_file.cc b/src/node_file.cc
index c1a936810f..4299945bbb 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -1819,7 +1819,7 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
if (is_async) { // write(fd, string, pos, enc, req)
CHECK_NOT_NULL(req_wrap_async);
- len = StringBytes::StorageSize(env->isolate(), value, enc);
+ if (!StringBytes::StorageSize(env->isolate(), value, enc).To(&len)) return;
FSReqBase::FSReqBuffer& stack_buffer =
req_wrap_async->Init("write", len, enc);
// StorageSize may return too large a char, so correct the actual length
@@ -1847,7 +1847,8 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
FSReqWrapSync req_wrap_sync;
FSReqBase::FSReqBuffer stack_buffer;
if (buf == nullptr) {
- len = StringBytes::StorageSize(env->isolate(), value, enc);
+ if (!StringBytes::StorageSize(env->isolate(), value, enc).To(&len))
+ return;
stack_buffer.AllocateSufficientStorage(len + 1);
// StorageSize may return too large a char, so correct the actual length
// by the write size