From a55c57b8c48d4d09d3fb74ffddab6e87d10f2030 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Wed, 29 Aug 2018 15:39:55 +0200 Subject: src: rework (mostly internal) functions to use Maybes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rework all affected functions to use Maybes, thus improving error handling substantially in internal functions, API functions as well as utilities. Co-authored-by: Michaƫl Zasso PR-URL: https://github.com/nodejs/node/pull/21935 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- src/util.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/util.cc') diff --git a/src/util.cc b/src/util.cc index b1b84d8f09..a0f0b0bf89 100644 --- a/src/util.cc +++ b/src/util.cc @@ -41,7 +41,9 @@ static void MakeUtf8String(Isolate* isolate, Local string; if (!value->ToString(isolate->GetCurrentContext()).ToLocal(&string)) return; - const size_t storage = StringBytes::StorageSize(isolate, string, UTF8) + 1; + size_t storage; + if (!StringBytes::StorageSize(isolate, string, UTF8).To(&storage)) return; + storage += 1; target->AllocateSufficientStorage(storage); const int flags = String::NO_NULL_TERMINATION | String::REPLACE_INVALID_UTF8; -- cgit v1.2.3