Fix for jid parsing.
authorMyhailo Danylenko <isbear@ukrpost.net>
Sat, 12 Dec 2009 01:24:18 +0200
changeset 13 339e8bf46039
parent 12 4d2ac929e61a
child 14 f43622080b3a
Fix for jid parsing.
disco.c
--- a/disco.c	Wed Nov 11 15:14:34 2009 +0200
+++ b/disco.c	Sat Dec 12 01:24:18 2009 +0200
@@ -188,15 +188,18 @@
 		char             *dnode   = NULL;
 		
 		if (args[0] && args[1]) {
-			if (*args[1] == '.') {
-				if (*(args[1] + 1) == JID_RESOURCE_SEPARATOR) { // allow "./resource" notation
-					char *rest = to_utf8 (args[1] + 1);
+			char *p = args[1];
+
+			if (*p == '.') {
+				if (*(p + 1) == JID_RESOURCE_SEPARATOR) {
+					char *rest = to_utf8 (p + 1);
 
 					to = g_strdup_printf ("%s%s", CURRENT_JID, rest);
 					g_free (rest);
-				}
+				} else if (*(p + 1))
+					to = to_utf8 (p);
 			} else
-				to = to_utf8 (args[1]);
+				to = to_utf8 (p);
 
 			if (args[2])
 				dnode = to_utf8 (args[2]);
@@ -219,7 +222,8 @@
 		lm_message_unref (request);
 		if (dnode)
 			g_free (dnode);
-		g_free (to);
+		if (to)
+			g_free (to);
 	}
 
 	free_arg_lst (args);