From ac357002ad6ecd24ad1b2adb4901259377452213 Mon Sep 17 00:00:00 2001 From: Clemens Hammacher Date: Mon, 14 May 2018 14:54:14 +0200 Subject: [PATCH] [msan] Remove alloc-dealloc mismatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A std::unique_ptr of array type uses the "delete[]" operator to delete the memory, hence we should use "new[]" to allocate it. I sometimes get this reported locally, even though I have "alloc_dealloc_mismatch=0" in ASAN_OPTIONS. So why not just fix it. R=marja@chromium.org Bug: v8:7754 Change-Id: I026287a0e0ee4b9560c4fc7333267e738392b13f Reviewed-on: https://chromium-review.googlesource.com/1057230 Reviewed-by: Marja Hölttä Commit-Queue: Clemens Hammacher Cr-Commit-Position: refs/heads/master@{#53154} --- src/ast/ast.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ast/ast.cc b/src/ast/ast.cc index 392af8a501..15b8bff61b 100644 --- a/src/ast/ast.cc +++ b/src/ast/ast.cc @@ -276,7 +276,9 @@ std::unique_ptr FunctionLiteral::GetDebugName() const { AllowHandleDereference allow_deref; return inferred_name_->ToCString(); } else { - return std::unique_ptr(new char{'\0'}); + char* empty_str = new char[1]; + empty_str[0] = 0; + return std::unique_ptr(empty_str); } // TODO(rmcilroy): Deal with two-character strings.