From 64220b6ab35745c56087641ceae9617ffb5be47a Mon Sep 17 00:00:00 2001
From: Hugo Lefeuvre <hugo.lefeuvre@savoirfairelinux.com>
Date: Thu, 19 Apr 2018 10:50:03 -0400
Subject: [PATCH] Fix new-delete-type-mismatch in ringdht/p2p

Do not delete an object of derived class type through a pointer to
its base class type that has a non-virtual destructor. Instead, the
base class should be defined with a virtual destructor. Deleting an
object through a pointer to a type without a virtual destructor
results in undefined behavior.

Change-Id: I5a9f1ade5d67056f9ebc2865bd3c1c17fe197fcf
Reviewed-by: Sebastien Blin <sebastien.blin@savoirfairelinux.com>
---
 src/ringdht/p2p.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/ringdht/p2p.cpp b/src/ringdht/p2p.cpp
index 2180a3214d..e1f30c5963 100644
--- a/src/ringdht/p2p.cpp
+++ b/src/ringdht/p2p.cpp
@@ -129,6 +129,7 @@ struct CtrlMsgBase
 {
     CtrlMsgBase() = delete;
     explicit CtrlMsgBase(CtrlMsgType id) : id_ {id} {}
+    virtual ~CtrlMsgBase() = default;
     CtrlMsgType type() const noexcept { return id_; }
 private:
     const CtrlMsgType id_;
-- 
GitLab