From 6ba36b4e03316466d89b345f3ef5de835ddee932 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Mon, 10 Feb 2025 05:49:50 -0500 Subject: [PATCH] src: disallow copy/move fns/constructors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/56811 Reviewed-By: Juan José Arboleda Reviewed-By: Daniel Lemire Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Chengzhong Wu --- src/debug_utils-inl.h | 2 +- src/util.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/debug_utils-inl.h b/src/debug_utils-inl.h index 86dc29d6bb..3736663d99 100644 --- a/src/debug_utils-inl.h +++ b/src/debug_utils-inl.h @@ -50,7 +50,7 @@ struct ToStringHelper { template >> - static std::string BaseConvert(T value) { + static std::string BaseConvert(T& value) { // NOLINT(runtime/references) return Convert(std::forward(value)); } }; diff --git a/src/util.h b/src/util.h index eb6da34877..84583d80c5 100644 --- a/src/util.h +++ b/src/util.h @@ -388,6 +388,11 @@ constexpr size_t strsize(const T (&)[N]) { template class MaybeStackBuffer { public: + // Disallow copy constructor + MaybeStackBuffer(const MaybeStackBuffer&) = delete; + // Disallow copy assignment operator + MaybeStackBuffer& operator=(const MaybeStackBuffer& other) = delete; + const T* out() const { return buf_; }