Fix a segfault when the selected item is not a valid disco target
(E.g. status buffer...)
--- 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)