Memory leak in the desctuctor MibLeaf:~MibLeaf

Hi, there is a memory leak in the destructor MibLeaf.
To fix the issue needs to be apply follow patch:

From cea87a7d2d686c49a27aecdd0b290401738993a1 Mon Sep 17 00:00:00 2001
From: Zinovkin <>
Date: Thu, 7 Sep 2023 15:57:35 +0300
Subject: del mem leak

diff --git a/agent++-4.6.1/src/mib.cpp b/agent++-4.6.1/src/mib.cpp
index 895a5ff..8403f91 100644
--- a/agent++-4.6.1/src/mib.cpp
+++ b/agent++-4.6.1/src/mib.cpp
@@ -108,6 +108,7 @@ MibLeaf::MibLeaf(const MibLeaf& other): MibEntry(other.oid, other.access)
+	if (undo) delete undo;
 void MibLeaf::init(SnmpSyntax* s, int mode)

Hi Mikhail,

That is not a real memory leak, because the 2-phase commit where the undo value is used, will always cleanup the value after use. Only if the cleanup method has a bug, this memory leak will happen.
The drawback of this change, could be that if a row or scalar MibLeaf object is being deleted while the cleanup is still running, you will get a segmentation fault.

Maybe I add the additional if statement for the delete but that requires some additional testing. In any case, it is not a real issue.

Best regards,