summaryrefslogtreecommitdiffstats
path: root/lib/memory.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2017-02-07 16:23:38 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2017-02-07 16:23:38 +0100
commitf65e2d40cc394b716d53ba80c846237c84a68cf0 (patch)
treee41005118546063140360bc8aa92d4c30423fc84 /lib/memory.c
parentMerge pull request #171 from donaldsharp/double_free (diff)
downloadfrr-f65e2d40cc394b716d53ba80c846237c84a68cf0.tar.xz
frr-f65e2d40cc394b716d53ba80c846237c84a68cf0.zip
lib: print backtrace on MTYPE count underflow
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/memory.c')
-rw-r--r--lib/memory.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/memory.c b/lib/memory.c
index f17915486..5fc008810 100644
--- a/lib/memory.c
+++ b/lib/memory.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "memory.h"
+#include "log.h"
static struct memgroup *mg_first = NULL;
struct memgroup **mg_insert = &mg_first;
@@ -40,6 +41,11 @@ mt_count_alloc (struct memtype *mt, size_t size)
static inline void
mt_count_free (struct memtype *mt)
{
+ if (mt->n_alloc == 0)
+ {
+ zlog_err ("memory allocation count underflow for \"%s\"", mt->name);
+ zlog_backtrace (LOG_ERR);
+ }
mt->n_alloc--;
}