From a4c21b1c82a3995944b59f0a3e318cefb9c443aa Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Tue, 22 Feb 2011 11:56:57 +0000 Subject: [PATCH] Check if the name is already used in add_debugger_command*() and reject duplicate attempt(s). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40611 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/debug/debug_commands.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/debug/debug_commands.cpp b/src/system/kernel/debug/debug_commands.cpp index 8e5a7ebf1b..c590b6bbd4 100644 --- a/src/system/kernel/debug/debug_commands.cpp +++ b/src/system/kernel/debug/debug_commands.cpp @@ -450,9 +450,12 @@ status_t add_debugger_command_etc(const char* name, debugger_command_hook func, const char* description, const char* usage, uint32 flags) { - struct debugger_command *cmd; + bool ambiguous; + debugger_command *cmd = find_debugger_command(name, false, ambiguous); + if (cmd != NULL && ambiguous == false) + return B_NAME_IN_USE; - cmd = (struct debugger_command*)malloc(sizeof(struct debugger_command)); + cmd = (debugger_command*)malloc(sizeof(debugger_command)); if (cmd == NULL) return B_NO_MEMORY;