[srvx-commits] CVS: services/src modcmd.c,1.19,1.20
Brought to you by:
entrope
|
From: Zoot <zo...@us...> - 2002-08-20 01:04:23
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv23792/src
Modified Files:
modcmd.c
Log Message:
Don't dereference a free'd pointer when cmd_unbind removes a binding to itself.
Index: modcmd.c
===================================================================
RCS file: /cvsroot/srvx/services/src/modcmd.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** modcmd.c 18 Aug 2002 16:04:33 -0000 1.19
--- modcmd.c 20 Aug 2002 01:04:20 -0000 1.20
***************
*** 902,905 ****
--- 902,906 ----
static MODCMD_FUNC(cmd_unbind) {
struct service *service;
+ struct userNode *bot;
struct svccmd *bound;
const char *svcname, *cmdname;
***************
*** 921,928 ****
return 0;
}
dict_remove(service->commands, bound->name);
service_rebuild_modules(service);
! send_message(user, cmd->parent->bot, MCMSG_COMMAND_UNBOUND, cmdname, service->bot->nick);
! return 1;
}
--- 922,939 ----
return 0;
}
+
+ /* If this command is removing a binding to itself, we (and
+ svccmd_invoke_argv) must take care not to dereference cmd.
+ Return 0 if so - we avoid the dereference, but the
+ invocation will not be logged; the alternative is to hoist
+ the log message generation above the dispatch.
+ */
+ bot = cmd->parent->bot;
+
dict_remove(service->commands, bound->name);
service_rebuild_modules(service);
! send_message(user, bot, MCMSG_COMMAND_UNBOUND, cmdname, service->bot->nick);
!
! return cmd == bound ? 0 : 1;
}
|