# HG changeset patch # User Mikael Berthe # Date 1289386051 -3600 # Node ID 1a62a570e66bfe759d69901f793cf91a414888d6 # Parent 104ecab6a1d5e8e080fba0d7766023c65ab4b6cb Fix a segfault when the selected item is not a valid disco target (E.g. status buffer...) diff -r 104ecab6a1d5 -r 1a62a570e66b disco.c --- a/disco.c Wed Nov 10 11:25:08 2010 +0100 +++ b/disco.c Wed Nov 10 11:47:31 2010 +0100 @@ -585,12 +585,31 @@ if (args[2]) dnode = to_utf8 (args[2]); } - // XXX send to all resources/current resource? + + if (!to) { + // Use currently selected item, if possible + if (current_buddy) { + gpointer bud = BUDDATA(current_buddy); + if (bud) { + guint type = buddy_gettype (bud); + if (type != ROSTER_TYPE_GROUP && type != ROSTER_TYPE_SPECIAL) + to = g_strdup (buddy_getjid (bud)); // XXX memleak! + } + } + } + + if (!to) { + scr_log_print (LPRINT_NORMAL, "Invalid disco target."); + free_arg_lst (args); + return; + } + + // XXX send to all resources/current resource? { disco_handler_t *cb = g_new (disco_handler_t, 1); - cb -> jid = to ? to : g_strdup (CURRENT_JID); + cb -> jid = to; cb -> node = dnode; if (info)