From 1eb5dae0bd0467d3a966c1d7af22610e2797ea57 Mon Sep 17 00:00:00 2001 From: GauthamBanasandra Date: Thu, 18 Jul 2019 00:11:38 +0530 Subject: [PATCH] src: add public virtual destructor for KVStore As KVStore has derived classes, it is essential to declare a public virtual destructor in the base KVStore class. Otherwise, deleting derived class instances using base class pointers would potentially cause undefined behaviour. Additionally, since we are implementing a non-default destructor, the special member functions have also been implemented in order to abide by the rule of five. PR-URL: https://github.com/nodejs/node/pull/28737 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott --- src/env.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/env.h b/src/env.h index 4e1629bb8ace16..a58b2a2b16358f 100644 --- a/src/env.h +++ b/src/env.h @@ -609,6 +609,13 @@ class AsyncRequest : public MemoryRetainer { class KVStore { public: + KVStore() = default; + virtual ~KVStore() = default; + KVStore(const KVStore&) = delete; + KVStore& operator=(const KVStore&) = delete; + KVStore(KVStore&&) = delete; + KVStore& operator=(KVStore&&) = delete; + virtual v8::Local Get(v8::Isolate* isolate, v8::Local key) const = 0; virtual void Set(v8::Isolate* isolate,