From 68e5373da4431f421f0972c8a677b4758174d99d Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 2 Oct 2018 12:03:27 +0200 Subject: [PATCH 1/3] src: add virtual desctructor to Options class Currently the Options class has a virtual function but no virtual destructor which means that if delete is called on a Options pointer to a derived instance, the derived destructor will not get called. The following warning is currently being printed when compiling: warning: delete called on non-final 'node::PerIsolateOptions' that has virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor] delete __ptr; This commit adds a virtual destructor. --- src/node_options.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node_options.h b/src/node_options.h index 32189dacfb080a..0e8af86218b641 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -24,6 +24,7 @@ struct HostPort { class Options { public: virtual void CheckOptions(std::vector* errors) {} + virtual ~Options() {} }; // These options are currently essentially per-Environment, but it can be nice From 0384ab7e683cc7b6b9f20e40835e20ed189c5827 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 2 Oct 2018 12:03:27 +0200 Subject: [PATCH 2/3] crypto: add virtual dtor to KeyPairGenerationConfig Currently the KeyPairGenerationConfigs class has a virtual function but no virtual destructor which means that if delete is called on a KeyPairGenerationConfig pointer to a derived instance, the derived destructor will not get called. The following warning is currently being printed when compiling: warning: delete called on 'node::crypto::KeyPairGenerationConfig' that is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor] delete __ptr; This commit adds a virtual destructor. --- src/node_crypto.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 2932df5a405424..19cdbba368fea1 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -4839,6 +4839,7 @@ class KeyPairGenerationConfig { virtual bool Configure(const EVPKeyCtxPointer& ctx) { return true; } + virtual ~KeyPairGenerationConfig() {} }; class RSAKeyPairGenerationConfig : public KeyPairGenerationConfig { From cbda824002b485c9898dc7b096bb7746d44e7f5f Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 2 Oct 2018 12:03:27 +0200 Subject: [PATCH 3/3] inspector: add virtual destructor to WorkerDelegate Currently the WorkerDelegate class has a virtual function but no virtual destructor which means that if delete is called on a WorkerDelegate pointer to a derived instance, the derived destructor will not get called. The following warning is currently being printed when compiling: warning: delete called on 'node::inspector::WorkerDelegate' that is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor] delete __ptr; ^ This commit adds a virtual destructor. --- src/inspector/worker_inspector.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/inspector/worker_inspector.h b/src/inspector/worker_inspector.h index e3c96cf62f01b0..c1d3b8a5711740 100644 --- a/src/inspector/worker_inspector.h +++ b/src/inspector/worker_inspector.h @@ -21,6 +21,7 @@ class WorkerDelegate { const std::string& url, bool waiting, std::shared_ptr worker) = 0; + virtual ~WorkerDelegate() {} }; class WorkerManagerEventHandle {