Do not crash when using say_to . on a special buffer item
This should fix issue #140.
--- a/mcabber/mcabber/commands.c Tue Sep 22 21:36:45 2015 +0200
+++ b/mcabber/mcabber/commands.c Thu Oct 01 22:44:29 2015 +0200
@@ -1690,14 +1690,24 @@
if (fjid[1] == '\0') {
fjid = g_strdup(cjid);
} else if (fjid[1] == JID_RESOURCE_SEPARATOR) {
- char *res_utf8 = to_utf8(fjid+2);
- fjid = g_strdup_printf("%s%c%s", cjid, JID_RESOURCE_SEPARATOR, res_utf8);
- g_free(res_utf8);
+ if (!cjid) {
+ fjid = NULL;
+ } else {
+ char *res_utf8 = to_utf8(fjid+2);
+ fjid = g_strdup_printf("%s%c%s", cjid, JID_RESOURCE_SEPARATOR, res_utf8);
+ g_free(res_utf8);
+ }
} else
fjid = to_utf8(fjid);
} else
fjid = to_utf8(fjid);
+ if (!fjid) {
+ scr_LogPrint(LPRINT_NORMAL, "The Jabber ID is invalid.");
+ free_arg_lst(paramlst);
+ return;
+ }
+
if (!strchr(fjid, JID_DOMAIN_SEPARATOR)) {
const gchar *append_server = settings_opt_get("default_server");
if (append_server) {