summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-10-15 08:59:11 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2015-10-15 08:59:11 -0400
commitb00d75adf63db155ef2873bd9d259dc8ca256be6 (patch)
treebbb8f9d2ef54abcf5a13178d588deec3fddeeeb7
parent159d23be9f1aa9e389b2bca8aec1bb673e2e2549 (diff)
add safety checking when setting up DEBUG bits4.4
-rw-r--r--libs/pbd/debug.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/libs/pbd/debug.cc b/libs/pbd/debug.cc
index af8cd052cd..e6d4abcee7 100644
--- a/libs/pbd/debug.cc
+++ b/libs/pbd/debug.cc
@@ -74,9 +74,21 @@ DebugBits PBD::debug_bits;
DebugBits
PBD::new_debug_bit (const char* name)
{
- DebugBits ret;
- ret.set (_debug_bit++, 1);
- _debug_bit_map().insert (make_pair (name, ret));
+ DebugBits ret;
+ DebugMap::iterator i =_debug_bit_map().find (name);
+
+ if (i != _debug_bit_map().end()) {
+ return i->second;
+ }
+
+ if (_debug_bit >= debug_bits.size()) {
+ cerr << "Too many debug bits defined, offender was " << name << endl;
+ abort ();
+ /*NOTREACHED*/
+ }
+
+ ret.set (_debug_bit++, 1);
+ _debug_bit_map().insert (make_pair (name, ret));
return ret;
}