[Orxonox-commit 3312] r8001 - code/branches/usability/src/libraries/core/input

rgrieder at orxonox.net rgrieder at orxonox.net
Mon Feb 28 05:49:01 CET 2011


Author: rgrieder
Date: 2011-02-28 05:49:01 +0100 (Mon, 28 Feb 2011)
New Revision: 8001

Modified:
   code/branches/usability/src/libraries/core/input/KeyBinder.cc
Log:
Fixed tiny memory leak.

Modified: code/branches/usability/src/libraries/core/input/KeyBinder.cc
===================================================================
--- code/branches/usability/src/libraries/core/input/KeyBinder.cc	2011-02-28 04:15:14 UTC (rev 8000)
+++ code/branches/usability/src/libraries/core/input/KeyBinder.cc	2011-02-28 04:49:01 UTC (rev 8001)
@@ -430,7 +430,13 @@
                             button->commands_[mode_index][c] = button->commands_[mode_index][c + 1];
                         // decrease counter
                         button->nCommands_[mode_index]--;
-                        // note: we don't replace the old array - it's not one element too large, but no one cares since nCommands_ defines the size
+                        // old array would not get deleted if nCommands_ is now 0
+                        // otherwise: nobody cares about an array that is one element too large - nCommands_ defines the size
+                        if (button->nCommands_[mode_index] == 0)
+                        {
+                            delete[] button->commands_[mode_index];
+                            button->nCommands_[mode_index] = 0;
+                        }
 
                         // decrement the index since we shifted the array and continue searching for more occurrences of the command
                         command_index--;




More information about the Orxonox-commit mailing list